新增:余额支付接口
This commit is contained in:
@@ -36,23 +36,49 @@ public class RequestUtil {
|
|||||||
ACCESS_TOKEN = token;
|
ACCESS_TOKEN = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 微信支付通知
|
// 预付请求付款(余额支付)
|
||||||
public void pushWxPayNotify(Transaction transaction){
|
public Object balancePay(Order order){
|
||||||
System.out.println("transaction = " + transaction);
|
|
||||||
// 设置租户ID
|
// 设置租户ID
|
||||||
// setTenantId(payment.getTenantId().toString());
|
setTenantId(order.getTenantId().toString());
|
||||||
// 推送支付通知地址
|
// 设置token
|
||||||
// String path = payment.getNotifyUrl();
|
setAccessToken(order.getAccessToken());
|
||||||
|
// 余额支付接口
|
||||||
|
String path = "/system/payment/balancePay";
|
||||||
try {
|
try {
|
||||||
// 链式构建请求
|
// 链式构建请求
|
||||||
String result = HttpRequest.post("http://pxf4av.natappfree.cc/api/shop/wx-pay/nbg/paySuccess")
|
final String body = HttpRequest.post(host.concat(path))
|
||||||
.header("Tenantid", "10158")
|
.header("Tenantid", TENANT_ID)
|
||||||
.body(JSONUtil.toJSONString(transaction))//表单内容
|
.header("Authorization", ACCESS_TOKEN)
|
||||||
|
.body(JSONUtil.toJSONString(order))//表单内容
|
||||||
.timeout(20000)//超时,毫秒
|
.timeout(20000)//超时,毫秒
|
||||||
.execute().body();
|
.execute().body();
|
||||||
|
|
||||||
|
return JSONUtil.parseObject(body, ApiResult.class).getData();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 微信支付通知
|
||||||
|
public String pushWxPayNotify(Transaction transaction, Payment payment){
|
||||||
|
// 设置租户ID
|
||||||
|
setTenantId(payment.getTenantId().toString());
|
||||||
|
// 推送支付通知地址
|
||||||
|
String path = payment.getNotifyUrl();
|
||||||
|
try {
|
||||||
|
// 链式构建请求
|
||||||
|
return HttpRequest.post(path)
|
||||||
|
.header("Tenantid", TENANT_ID)
|
||||||
|
.body(JSONUtil.toJSONString(transaction))//表单内容
|
||||||
|
.timeout(20000)//超时,毫秒
|
||||||
|
.execute().body();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "支付失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,25 +36,25 @@ import java.util.stream.Collectors;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/shop/cart")
|
@RequestMapping("/api/shop/cart")
|
||||||
public class CartController extends BaseController {
|
public class CartController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private CartService cartService;
|
private CartService cartService;
|
||||||
@Resource
|
@Resource
|
||||||
private MerchantService merchantService;
|
private MerchantService merchantService;
|
||||||
|
|
||||||
@ApiOperation("我的购物车")
|
@ApiOperation("我的购物车")
|
||||||
@GetMapping("/myCart")
|
@GetMapping("/myCart")
|
||||||
public ApiResult<?> myCart(CartParam param){
|
public ApiResult<?> myCart(CartParam param) {
|
||||||
HashMap<String, Object> map = computeCart(param);
|
HashMap<String, Object> map = computeCart(param);
|
||||||
|
|
||||||
// 记录当前登录用户id
|
// 记录当前登录用户id
|
||||||
User loginUser = getLoginUser();
|
User loginUser = getLoginUser();
|
||||||
if (loginUser == null) {
|
if (loginUser == null) {
|
||||||
return fail("请先登录",null);
|
return fail("请先登录", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询购物车
|
// 查询购物车
|
||||||
param.setUserId(loginUser.getUserId());
|
param.setUserId(loginUser.getUserId());
|
||||||
final List<Cart> carts = cartService.listRelMpj(param);
|
final List<Cart> carts = cartService.listRelMpj(param);
|
||||||
|
|
||||||
// final List<Cart> carts = cartService.list(new LambdaQueryWrapper<Cart>()
|
// final List<Cart> carts = cartService.list(new LambdaQueryWrapper<Cart>()
|
||||||
// .eq(Cart::getUserId, loginUser.getUserId())
|
// .eq(Cart::getUserId, loginUser.getUserId())
|
||||||
@@ -63,163 +63,177 @@ public class CartController extends BaseController {
|
|||||||
// .eq(Cart::getDeleted, 0)
|
// .eq(Cart::getDeleted, 0)
|
||||||
// .last("limit 100"));
|
// .last("limit 100"));
|
||||||
|
|
||||||
// 收集店铺ID
|
// 收集店铺ID
|
||||||
final Set<Integer> merchantIds = carts.stream().map(Cart::getMerchantId).collect(Collectors.toSet());
|
final Set<Integer> merchantIds = carts.stream().map(Cart::getMerchantId).collect(Collectors.toSet());
|
||||||
if (CollectionUtils.isEmpty(merchantIds)) {
|
if (CollectionUtils.isEmpty(merchantIds)) {
|
||||||
map.put("selectAll",false);
|
map.put("selectAll", false);
|
||||||
return success(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询店铺列
|
|
||||||
final List<Merchant> merchants = merchantService.list(new LambdaQueryWrapper<Merchant>()
|
|
||||||
.select(Merchant::getMerchantId,Merchant::getMerchantName,Merchant::getImage,Merchant::getShopType, Merchant::getAddress)
|
|
||||||
.in(Merchant::getMerchantId, merchantIds));
|
|
||||||
|
|
||||||
// 返回空列表
|
|
||||||
if (CollectionUtils.isEmpty(merchants)) {
|
|
||||||
return success(merchants);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Map<Integer, List<Cart>> collect = carts.stream().collect(Collectors.groupingBy(Cart::getMerchantId));
|
|
||||||
|
|
||||||
// 封装数据
|
|
||||||
merchants.forEach(d -> {
|
|
||||||
d.setCarts(collect.get(d.getMerchantId()));
|
|
||||||
});
|
|
||||||
|
|
||||||
// 计算购物车金额
|
|
||||||
map.put("merchants",merchants);
|
|
||||||
|
|
||||||
return success(map);
|
return success(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("添加购物车")
|
// 查询店铺列
|
||||||
@PostMapping()
|
final List<Merchant> merchants = merchantService.list(new LambdaQueryWrapper<Merchant>()
|
||||||
public ApiResult<?> save(@RequestBody Cart cart) {
|
.select(Merchant::getMerchantId, Merchant::getMerchantName, Merchant::getImage, Merchant::getShopType, Merchant::getAddress)
|
||||||
|
.in(Merchant::getMerchantId, merchantIds));
|
||||||
|
|
||||||
// 记录当前登录用户id
|
// 返回空列表
|
||||||
User loginUser = getLoginUser();
|
if (CollectionUtils.isEmpty(merchants)) {
|
||||||
if (loginUser == null) {
|
return success(merchants);
|
||||||
return fail("请先登录");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询参数
|
|
||||||
final CartParam param = new CartParam();
|
|
||||||
param.setType(cart.getType());
|
|
||||||
|
|
||||||
// 购物车是否已存在
|
|
||||||
final Cart item = cartService.getOne(new LambdaQueryWrapper<Cart>()
|
|
||||||
.eq(Cart::getUserId, loginUser.getUserId())
|
|
||||||
.eq(Cart::getGoodsId, cart.getGoodsId())
|
|
||||||
.eq(Cart::getType,cart.getType())
|
|
||||||
.last("limit 1"));
|
|
||||||
|
|
||||||
cart.setUserId(loginUser.getUserId());
|
|
||||||
// 字段验证
|
|
||||||
if(cart.getCartNum() == null){
|
|
||||||
return fail("购买数量不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("cart = " + cart);
|
|
||||||
|
|
||||||
// 修改购物车
|
|
||||||
if (item != null) {
|
|
||||||
item.setCartNum(item.getCartNum() + cart.getCartNum());
|
|
||||||
cartService.updateById(item);
|
|
||||||
|
|
||||||
return success("添加成功",computeCart(param));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新添加商品
|
|
||||||
if (cartService.save(cart)) {
|
|
||||||
return success("添加成功",computeCart(param));
|
|
||||||
}
|
|
||||||
|
|
||||||
return fail("添加失败");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改购物车")
|
final Map<Integer, List<Cart>> collect = carts.stream().collect(Collectors.groupingBy(Cart::getMerchantId));
|
||||||
@PutMapping()
|
|
||||||
public ApiResult<?> update(@RequestBody Cart cart) {
|
|
||||||
if (cartService.updateById(cart)) {
|
|
||||||
final CartParam param = new CartParam();
|
|
||||||
param.setType(cart.getType());
|
|
||||||
return success("修改成功",computeCart(param));
|
|
||||||
}
|
|
||||||
return fail("修改失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("计算购物车金额")
|
// 封装数据
|
||||||
@GetMapping("/count")
|
merchants.forEach(d -> {
|
||||||
public HashMap<String, Object> computeCart(CartParam param) {
|
d.setCarts(collect.get(d.getMerchantId()));
|
||||||
final LambdaQueryWrapper<Cart> queryWrapper = new LambdaQueryWrapper<>();
|
});
|
||||||
|
|
||||||
queryWrapper.select(Cart::getId,Cart::getPrice,Cart::getCartNum)
|
// 计算购物车金额
|
||||||
.eq(Cart::getUserId, getLoginUserId())
|
map.put("merchants", merchants);
|
||||||
.eq(Cart::getType,param.getType())
|
|
||||||
.eq(Cart::getSelected,1)
|
|
||||||
.eq(Cart::getIsPay, 0);
|
|
||||||
|
|
||||||
// 查询购物车数据
|
return success(map);
|
||||||
final List<Cart> carts = cartService.list(queryWrapper);
|
}
|
||||||
|
|
||||||
// 计算单品合计价格
|
@ApiOperation("添加购物车")
|
||||||
carts.forEach(d -> {
|
@PostMapping()
|
||||||
d.setTotalPrice(d.getPrice().multiply(BigDecimal.valueOf(d.getCartNum())));
|
public ApiResult<?> save(@RequestBody Cart cart) {
|
||||||
});
|
|
||||||
|
|
||||||
// 保存到数据库
|
// 记录当前登录用户id
|
||||||
cartService.updateBatchById(carts);
|
User loginUser = getLoginUser();
|
||||||
|
if (loginUser == null) {
|
||||||
// 计算购物车金额
|
return fail("请先登录");
|
||||||
final Integer reduce = carts.stream().map(Cart::getCartNum).reduce(Integer::sum).orElse(0);
|
|
||||||
final BigDecimal reduced = carts.stream().map(Cart::getTotalPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
// 是否全选
|
|
||||||
Boolean selectAll = cartService.count(new LambdaQueryWrapper<Cart>()
|
|
||||||
.eq(Cart::getUserId, getLoginUserId())
|
|
||||||
.eq(Cart::getSelected, 0)
|
|
||||||
.eq(Cart::getIsPay, 0)
|
|
||||||
) == 0;
|
|
||||||
|
|
||||||
|
|
||||||
// 返回给前端
|
|
||||||
final HashMap<String, Object> map = new HashMap<>();
|
|
||||||
map.put("totalCartNum",reduce);
|
|
||||||
map.put("totalPrice",reduced);
|
|
||||||
map.put("selectAll",selectAll);
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("全选操作")
|
|
||||||
@PutMapping("/onSelectAll/{yes}")
|
|
||||||
public ApiResult<?> onSelectAll(@PathVariable("yes") Boolean yes) {
|
|
||||||
final CartParam param = new CartParam();
|
|
||||||
param.setType(0);
|
|
||||||
|
|
||||||
// 是否全选
|
|
||||||
if (yes.equals(true)) {
|
|
||||||
// 全勾选
|
|
||||||
cartService.update(new LambdaUpdateWrapper<Cart>()
|
|
||||||
.eq(Cart::getUserId, getLoginUserId())
|
|
||||||
.eq(Cart::getIsPay, 0)
|
|
||||||
.eq(Cart::getSelected,0)
|
|
||||||
.set(Cart::getSelected,1)
|
|
||||||
);
|
|
||||||
return success("修改成功",computeCart(param));
|
|
||||||
}
|
}
|
||||||
// 全不勾选
|
// 附加用户ID
|
||||||
|
cart.setUserId(loginUser.getUserId());
|
||||||
|
|
||||||
|
// 字段验证
|
||||||
|
if (cart.getCartNum() == null) {
|
||||||
|
return fail("购买数量不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 立即购买按钮
|
||||||
|
if(cart.getIsNew() != null && cart.getIsNew()){
|
||||||
|
cartService.save(cart);
|
||||||
|
return success(cart);
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<Cart> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
if (cart.getIsNew() != null) {
|
||||||
|
queryWrapper.eq(Cart::getIsNew,cart.getIsNew());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 购物车是否已存在
|
||||||
|
queryWrapper.eq(Cart::getUserId, loginUser.getUserId())
|
||||||
|
.eq(Cart::getGoodsId, cart.getGoodsId())
|
||||||
|
.eq(Cart::getType, cart.getType())
|
||||||
|
.last("limit 1");
|
||||||
|
|
||||||
|
Cart item = cartService.getOne(queryWrapper);
|
||||||
|
|
||||||
|
// 查询购物车的参数
|
||||||
|
final CartParam param = new CartParam();
|
||||||
|
param.setType(cart.getType());
|
||||||
|
if (cart.getIsNew() != null) {
|
||||||
|
param.setIsNew(cart.getIsNew());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重复商品叠加数量
|
||||||
|
if(item != null){
|
||||||
|
System.out.println("item = " + item);
|
||||||
|
item.setCartNum(item.getCartNum() + cart.getCartNum());
|
||||||
|
if (cartService.updateById(item)) {
|
||||||
|
return success("更新成功", computeCart(param));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新添加商品
|
||||||
|
if (cartService.save(cart)) {
|
||||||
|
return success("添加成功", computeCart(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
return fail("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("修改购物车")
|
||||||
|
@PutMapping()
|
||||||
|
public ApiResult<?> update(@RequestBody Cart cart) {
|
||||||
|
if (cartService.updateById(cart)) {
|
||||||
|
final CartParam param = new CartParam();
|
||||||
|
param.setType(cart.getType());
|
||||||
|
return success("修改成功", computeCart(param));
|
||||||
|
}
|
||||||
|
return fail("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("计算购物车金额")
|
||||||
|
@GetMapping("/count")
|
||||||
|
public HashMap<String, Object> computeCart(CartParam param) {
|
||||||
|
final LambdaQueryWrapper<Cart> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
queryWrapper.select(Cart::getId, Cart::getPrice, Cart::getCartNum)
|
||||||
|
.eq(Cart::getUserId, getLoginUserId())
|
||||||
|
.eq(Cart::getType, param.getType())
|
||||||
|
.eq(Cart::getSelected, 1)
|
||||||
|
.eq(Cart::getIsPay, 0);
|
||||||
|
|
||||||
|
// 查询购物车数据
|
||||||
|
final List<Cart> carts = cartService.list(queryWrapper);
|
||||||
|
|
||||||
|
// 计算单品合计价格
|
||||||
|
carts.forEach(d -> {
|
||||||
|
d.setTotalPrice(d.getPrice().multiply(BigDecimal.valueOf(d.getCartNum())));
|
||||||
|
});
|
||||||
|
|
||||||
|
// 保存到数据库
|
||||||
|
cartService.updateBatchById(carts);
|
||||||
|
|
||||||
|
// 计算购物车金额
|
||||||
|
final Integer reduce = carts.stream().map(Cart::getCartNum).reduce(Integer::sum).orElse(0);
|
||||||
|
final BigDecimal reduced = carts.stream().map(Cart::getTotalPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
|
||||||
|
// 是否全选
|
||||||
|
Boolean selectAll = cartService.count(new LambdaQueryWrapper<Cart>()
|
||||||
|
.eq(Cart::getUserId, getLoginUserId())
|
||||||
|
.eq(Cart::getSelected, 0)
|
||||||
|
.eq(Cart::getIsPay, 0)
|
||||||
|
) == 0;
|
||||||
|
|
||||||
|
|
||||||
|
// 返回给前端
|
||||||
|
final HashMap<String, Object> map = new HashMap<>();
|
||||||
|
map.put("totalCartNum", reduce);
|
||||||
|
map.put("totalPrice", reduced);
|
||||||
|
map.put("selectAll", selectAll);
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("全选操作")
|
||||||
|
@PutMapping("/onSelectAll/{yes}")
|
||||||
|
public ApiResult<?> onSelectAll(@PathVariable("yes") Boolean yes) {
|
||||||
|
final CartParam param = new CartParam();
|
||||||
|
param.setType(0);
|
||||||
|
|
||||||
|
// 是否全选
|
||||||
|
if (yes.equals(true)) {
|
||||||
|
// 全勾选
|
||||||
cartService.update(new LambdaUpdateWrapper<Cart>()
|
cartService.update(new LambdaUpdateWrapper<Cart>()
|
||||||
.eq(Cart::getUserId, getLoginUserId())
|
.eq(Cart::getUserId, getLoginUserId())
|
||||||
.eq(Cart::getIsPay, 0)
|
.eq(Cart::getIsPay, 0)
|
||||||
.eq(Cart::getSelected,1)
|
.eq(Cart::getSelected, 0)
|
||||||
.set(Cart::getSelected,0)
|
.set(Cart::getSelected, 1)
|
||||||
);
|
);
|
||||||
return success("修改成功",computeCart(param));
|
return success("修改成功", computeCart(param));
|
||||||
}
|
}
|
||||||
|
// 全不勾选
|
||||||
|
cartService.update(new LambdaUpdateWrapper<Cart>()
|
||||||
|
.eq(Cart::getUserId, getLoginUserId())
|
||||||
|
.eq(Cart::getIsPay, 0)
|
||||||
|
.eq(Cart::getSelected, 1)
|
||||||
|
.set(Cart::getSelected, 0)
|
||||||
|
);
|
||||||
|
return success("修改成功", computeCart(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// @ApiOperation("按店铺ID更新选择状态")
|
// @ApiOperation("按店铺ID更新选择状态")
|
||||||
@@ -233,62 +247,62 @@ public class CartController extends BaseController {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("分页查询购物车")
|
@ApiOperation("分页查询购物车")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public ApiResult<PageResult<Cart>> page(CartParam param) {
|
public ApiResult<PageResult<Cart>> page(CartParam param) {
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
return success(cartService.pageRel(param));
|
return success(cartService.pageRel(param));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询全部购物车")
|
@ApiOperation("查询全部购物车")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public ApiResult<List<Cart>> list(CartParam param) {
|
public ApiResult<List<Cart>> list(CartParam param) {
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
return success(cartService.listRel(param));
|
return success(cartService.listRel(param));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('shop:cart:list')")
|
@PreAuthorize("hasAuthority('shop:cart:list')")
|
||||||
@ApiOperation("根据id查询购物车")
|
@ApiOperation("根据id查询购物车")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ApiResult<Cart> get(@PathVariable("id") Integer id) {
|
public ApiResult<Cart> get(@PathVariable("id") Integer id) {
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
return success(cartService.getByIdRel(id));
|
return success(cartService.getByIdRel(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除购物车")
|
@ApiOperation("删除购物车")
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||||
if (cartService.removeById(id)) {
|
if (cartService.removeById(id)) {
|
||||||
return success("删除成功");
|
return success("删除成功");
|
||||||
}
|
|
||||||
return fail("删除失败");
|
|
||||||
}
|
}
|
||||||
|
return fail("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("批量添加购物车")
|
@ApiOperation("批量添加购物车")
|
||||||
@PostMapping("/batch")
|
@PostMapping("/batch")
|
||||||
public ApiResult<?> saveBatch(@RequestBody List<Cart> list) {
|
public ApiResult<?> saveBatch(@RequestBody List<Cart> list) {
|
||||||
if (cartService.saveBatch(list)) {
|
if (cartService.saveBatch(list)) {
|
||||||
return success("添加成功");
|
return success("添加成功");
|
||||||
}
|
|
||||||
return fail("添加失败");
|
|
||||||
}
|
}
|
||||||
|
return fail("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("批量修改购物车")
|
@ApiOperation("批量修改购物车")
|
||||||
@PutMapping("/batch")
|
@PutMapping("/batch")
|
||||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Cart> batchParam) {
|
public ApiResult<?> removeBatch(@RequestBody BatchParam<Cart> batchParam) {
|
||||||
if (batchParam.update(cartService, "id")) {
|
if (batchParam.update(cartService, "id")) {
|
||||||
return success("修改成功");
|
return success("修改成功");
|
||||||
}
|
|
||||||
return fail("修改失败");
|
|
||||||
}
|
}
|
||||||
|
return fail("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("批量删除购物车")
|
@ApiOperation("批量删除购物车")
|
||||||
@DeleteMapping("/batch")
|
@DeleteMapping("/batch")
|
||||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||||
if (cartService.removeByIds(ids)) {
|
if (cartService.removeByIds(ids)) {
|
||||||
return success("删除成功");
|
return success("删除成功");
|
||||||
}
|
|
||||||
return fail("删除失败");
|
|
||||||
}
|
}
|
||||||
|
return fail("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ public class OrderController extends BaseController {
|
|||||||
// TODO 余额支付
|
// TODO 余额支付
|
||||||
if (order.getPayType().equals(0)) {
|
if (order.getPayType().equals(0)) {
|
||||||
order.setAccessToken(order.getAccessToken());
|
order.setAccessToken(order.getAccessToken());
|
||||||
return success("下单成功", orderService.payByBalance(order));
|
return success("下单成功", requestUtil.balancePay(order));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 微信统一下单接口
|
// TODO 微信统一下单接口
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@Api(tags = "微信支付结果通知")
|
@Api(tags = "微信支付结果通知")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/shop/wx-pay/nbg")
|
@RequestMapping("/api/shop/wx-pay/notify/nbg")
|
||||||
public class WxPayNotifyNbgController extends BaseController {
|
public class WxPayNotifyNbgController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
@@ -52,7 +52,7 @@ public class WxPayNotifyNbgController extends BaseController {
|
|||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
@ApiModelProperty("微信支付通知")
|
@ApiModelProperty("微信支付通知")
|
||||||
@PostMapping("/notify")
|
@PostMapping()
|
||||||
public String demo(@RequestBody Transaction transaction){
|
public String demo(@RequestBody Transaction transaction){
|
||||||
|
|
||||||
System.out.println("支付通知 >>>>> ");
|
System.out.println("支付通知 >>>>> ");
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ public class CartServiceImpl extends ServiceImpl<CartMapper, Cart> implements Ca
|
|||||||
if(param.getType() != null){
|
if(param.getType() != null){
|
||||||
mpjLambdaWrapper.eq(Cart::getType,param.getType());
|
mpjLambdaWrapper.eq(Cart::getType,param.getType());
|
||||||
}
|
}
|
||||||
|
if(param.getIsNew() != null){
|
||||||
|
mpjLambdaWrapper.eq(Cart::getIsNew,param.getIsNew());
|
||||||
|
}
|
||||||
|
|
||||||
return baseMapper.selectJoinList(Cart.class, mpjLambdaWrapper);
|
return baseMapper.selectJoinList(Cart.class, mpjLambdaWrapper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|||||||
.select(GoodsSpec::getSpecValue)
|
.select(GoodsSpec::getSpecValue)
|
||||||
.select(GoodsSpec::getSpecName)
|
.select(GoodsSpec::getSpecName)
|
||||||
.leftJoin(GoodsSpec.class,GoodsSpec::getGoodsId,GoodsSpec::getGoodsId)
|
.leftJoin(GoodsSpec.class,GoodsSpec::getGoodsId,GoodsSpec::getGoodsId)
|
||||||
|
.gt(Goods::getStock,0)
|
||||||
.eq(Goods::getType,0);
|
.eq(Goods::getType,0);
|
||||||
return baseMapper.selectJoinList(Goods.class, mpjLambdaWrapper);
|
return baseMapper.selectJoinList(Goods.class, mpjLambdaWrapper);
|
||||||
}
|
}
|
||||||
@@ -135,6 +136,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|||||||
.select(GoodsSpec::getSpecValue)
|
.select(GoodsSpec::getSpecValue)
|
||||||
.select(GoodsSpec::getSpecName)
|
.select(GoodsSpec::getSpecName)
|
||||||
.leftJoin(GoodsSpec.class,GoodsSpec::getGoodsId,GoodsSpec::getGoodsId)
|
.leftJoin(GoodsSpec.class,GoodsSpec::getGoodsId,GoodsSpec::getGoodsId)
|
||||||
|
.gt(Goods::getStock,0)
|
||||||
.eq(Goods::getType,1);
|
.eq(Goods::getType,1);
|
||||||
return baseMapper.selectJoinList(Goods.class, mpjLambdaWrapper);
|
return baseMapper.selectJoinList(Goods.class, mpjLambdaWrapper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ import com.gxwebsoft.shop.param.OrderParam;
|
|||||||
import com.gxwebsoft.shop.service.*;
|
import com.gxwebsoft.shop.service.*;
|
||||||
import com.wechat.pay.java.core.Config;
|
import com.wechat.pay.java.core.Config;
|
||||||
import com.wechat.pay.java.core.RSAConfig;
|
import com.wechat.pay.java.core.RSAConfig;
|
||||||
|
import com.gxwebsoft.common.system.entity.Payment;
|
||||||
|
import com.wechat.pay.java.service.partnerpayments.jsapi.model.Transaction;
|
||||||
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||||
import com.wechat.pay.java.service.payments.jsapi.model.Amount;
|
import com.wechat.pay.java.service.payments.jsapi.model.Amount;
|
||||||
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
|
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
|
||||||
|
|||||||
Reference in New Issue
Block a user