240401
This commit is contained in:
@@ -1,14 +1,31 @@
|
||||
package com.gxwebsoft.shop.constants;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class OrderConstants {
|
||||
// 订单来源 10普通订单 20砍价订单 30秒杀订单
|
||||
public static final Integer ORDER_SOURCE = 10; // 普通订单
|
||||
public static final Integer ORDER_SOURCE_BARGAIN = 20; // 砍价订单
|
||||
public static final Integer ORDER_SOURCE_SHARP= 30; // 秒杀订单
|
||||
public static final Integer ORDER_STATUS_CANCEL = 0;
|
||||
public static final Integer ORDER_STATUS_UNPAID = 1;
|
||||
public static final Integer ORDER_STATUS_PAID= 2;
|
||||
public static final Integer ORDER_STATUS_DONE = 3;
|
||||
public static final Integer ORDER_STATUS_REFUNDING = 4;
|
||||
public static final Integer ORDER_STATUS_REFUND_SUCCESS = 5;
|
||||
public static final Integer ORDER_STATUS_REFUND_FAIL = 6;
|
||||
public static final Integer ORDER_STATUS_USED = 7;
|
||||
|
||||
// 订单商品
|
||||
public static final Integer ORDER_GOODS_DELIVERY_STATUS10 = 10; // 未发货
|
||||
public static final Integer ORDER_GOODS_DELIVERY_STATUS20 = 20; // 已发货
|
||||
public static final Integer ORDER_GOODS_DELIVERY_STATUS30 = 30; // 部分发货
|
||||
public static final Map<Integer, String> ORDER_STATUS_MAP = new HashMap<Integer, String>(){{
|
||||
put(ORDER_STATUS_CANCEL, "已取消");
|
||||
put(ORDER_STATUS_UNPAID, "待支付");
|
||||
put(ORDER_STATUS_PAID, "已支付");
|
||||
put(ORDER_STATUS_DONE, "已结束");
|
||||
put(ORDER_STATUS_REFUNDING, "退款审核中");
|
||||
put(ORDER_STATUS_REFUND_SUCCESS, "退款成功");
|
||||
put(ORDER_STATUS_REFUND_FAIL, "退款失败");
|
||||
put(ORDER_STATUS_USED, "已出险");
|
||||
}};
|
||||
|
||||
public static final Integer ORDER_PAY_METHOD_CODE = 0;
|
||||
public static final Integer ORDER_PAY_METHOD_WECHAT = 1;
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,11 @@ public class CategoryController extends BaseController {
|
||||
@Resource
|
||||
private CategoryService categoryService;
|
||||
|
||||
@PostMapping("/list")
|
||||
public ApiResult<List<Category>> listForFront() {
|
||||
return success(categoryService.list());
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:category:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商品分类表")
|
||||
|
||||
@@ -7,8 +7,14 @@ import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.entity.Goods;
|
||||
import com.gxwebsoft.shop.entity.GoodsPrice;
|
||||
import com.gxwebsoft.shop.param.GoodsParam;
|
||||
import com.gxwebsoft.shop.param.GoodsPhoneModelParam;
|
||||
import com.gxwebsoft.shop.service.GoodsPhoneModelService;
|
||||
import com.gxwebsoft.shop.service.GoodsPriceService;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
import com.gxwebsoft.vivo.entity.VivoPhoneModel;
|
||||
import com.gxwebsoft.vivo.param.VivoPhoneModelParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -29,17 +35,62 @@ import java.util.List;
|
||||
public class GoodsController extends BaseController {
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Resource
|
||||
private GoodsPhoneModelService goodsPhoneModelService;
|
||||
@Resource
|
||||
private GoodsPriceService goodsPriceService;
|
||||
|
||||
|
||||
@PostMapping("/list")
|
||||
public ApiResult<List<Goods>> listForFront(@RequestBody GoodsParam param) {
|
||||
List<Goods> goodsList = goodsService.listRel(param);
|
||||
goodsService.setData(goodsList, getLoginUser());
|
||||
return success(goodsList);
|
||||
}
|
||||
|
||||
@PostMapping("/info")
|
||||
public ApiResult<Goods> info(@RequestBody GoodsParam param) {
|
||||
Goods goods = goodsService.getById(param.getGoodsId());
|
||||
User loginUser = getLoginUser();
|
||||
GoodsPrice goodsPrice = goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId());
|
||||
goods.setGoodsPrice(goodsPrice);
|
||||
return success(goods);
|
||||
}
|
||||
|
||||
@PostMapping("/info-by-phone-code")
|
||||
public ApiResult<?> infoByPhoneCode(@RequestBody VivoPhoneModelParam phoneModelParam) {
|
||||
List<Goods> goodsList = goodsService.getByPhoneModelCode(phoneModelParam.getCode());
|
||||
User loginUser = getLoginUser();
|
||||
if (goodsList.isEmpty()) return fail("该机型暂无碎屏宝");
|
||||
goodsList.forEach(goods -> {
|
||||
GoodsPrice goodsPrice = goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId());
|
||||
goods.setGoodsPrice(goodsPrice);
|
||||
});
|
||||
return success(goodsList);
|
||||
}
|
||||
|
||||
@PostMapping("/info-by-phone-model")
|
||||
public ApiResult<?> infoByPhoneModel(@RequestBody VivoPhoneModelParam phoneModelParam) {
|
||||
List<Goods> goodsList = goodsService.getByPhoneModel(phoneModelParam.getName());
|
||||
User loginUser = getLoginUser();
|
||||
if (goodsList == null) return fail("该机型暂无碎屏宝");
|
||||
goodsList.forEach(goods -> {
|
||||
GoodsPrice goodsPrice = goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId());
|
||||
goods.setGoodsPrice(goodsPrice);
|
||||
});
|
||||
return success(goodsList);
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商品记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Goods>> page(GoodsParam param) {
|
||||
// PageParam<Goods, GoodsParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(goodsService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
return success(goodsService.pageRel(param));
|
||||
PageResult<Goods> page = goodsService.pageRel(param);
|
||||
goodsService.setData(page.getList(), getLoginUser());
|
||||
return success(page);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:list')")
|
||||
@@ -51,7 +102,9 @@ public class GoodsController extends BaseController {
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(goodsService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
return success(goodsService.listRel(param));
|
||||
List<Goods> goodsList = goodsService.listRel(param);
|
||||
goodsService.setData(goodsList, getLoginUser());
|
||||
return success(goodsList);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:list')")
|
||||
@@ -72,9 +125,12 @@ public class GoodsController extends BaseController {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
goods.setUserId(loginUser.getUserId());
|
||||
goods.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (goodsService.save(goods)) {
|
||||
if (goods.getGoodsPhoneModelList() != null) {
|
||||
addPhoneModel(goods);
|
||||
}
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
@@ -86,11 +142,22 @@ public class GoodsController extends BaseController {
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Goods goods) {
|
||||
if (goodsService.updateById(goods)) {
|
||||
addPhoneModel(goods);
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
private void addPhoneModel(Goods goods) {
|
||||
if (goods.getGoodsPhoneModelList() != null) {
|
||||
goodsPhoneModelService.delByGoodsId(goods.getGoodsId());
|
||||
goods.getGoodsPhoneModelList().forEach(goodsPhoneModel -> {
|
||||
goodsPhoneModel.setGoodsId(goods.getGoodsId());
|
||||
});
|
||||
goodsPhoneModelService.saveBatch(goods.getGoodsPhoneModelList());
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商品记录表")
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.GoodsPhoneModelService;
|
||||
import com.gxwebsoft.shop.entity.GoodsPhoneModel;
|
||||
import com.gxwebsoft.shop.param.GoodsPhoneModelParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品匹配机型控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:30:55
|
||||
*/
|
||||
@Api(tags = "商品匹配机型管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/goods-phone-model")
|
||||
public class GoodsPhoneModelController extends BaseController {
|
||||
@Resource
|
||||
private GoodsPhoneModelService goodsPhoneModelService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPhoneModel:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商品匹配机型")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<GoodsPhoneModel>> page(GoodsPhoneModelParam param) {
|
||||
PageParam<GoodsPhoneModel, GoodsPhoneModelParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(goodsPhoneModelService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(goodsPhoneModelService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPhoneModel:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商品匹配机型")
|
||||
@GetMapping()
|
||||
public ApiResult<List<GoodsPhoneModel>> list(GoodsPhoneModelParam param) {
|
||||
PageParam<GoodsPhoneModel, GoodsPhoneModelParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(goodsPhoneModelService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(goodsPhoneModelService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPhoneModel:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商品匹配机型")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<GoodsPhoneModel> get(@PathVariable("id") Integer id) {
|
||||
return success(goodsPhoneModelService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(goodsPhoneModelService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPhoneModel:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商品匹配机型")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody GoodsPhoneModel goodsPhoneModel) {
|
||||
if (goodsPhoneModelService.save(goodsPhoneModel)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPhoneModel:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商品匹配机型")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody GoodsPhoneModel goodsPhoneModel) {
|
||||
if (goodsPhoneModelService.updateById(goodsPhoneModel)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPhoneModel:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商品匹配机型")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (goodsPhoneModelService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPhoneModel:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商品匹配机型")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<GoodsPhoneModel> list) {
|
||||
if (goodsPhoneModelService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPhoneModel:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商品匹配机型")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<GoodsPhoneModel> batchParam) {
|
||||
if (batchParam.update(goodsPhoneModelService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPhoneModel:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商品匹配机型")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsPhoneModelService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.Area;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.AreaService;
|
||||
import com.gxwebsoft.shop.service.GoodsPriceService;
|
||||
import com.gxwebsoft.shop.entity.GoodsPrice;
|
||||
import com.gxwebsoft.shop.param.GoodsPriceParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品价格()控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:35:40
|
||||
*/
|
||||
@Api(tags = "商品价格()管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/goods-price")
|
||||
public class GoodsPriceController extends BaseController {
|
||||
@Resource
|
||||
private GoodsPriceService goodsPriceService;
|
||||
@Resource
|
||||
private AreaService areaService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商品价格()")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<GoodsPrice>> page(GoodsPriceParam param) {
|
||||
PageParam<GoodsPrice, GoodsPriceParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(goodsPriceService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(goodsPriceService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商品价格()")
|
||||
@GetMapping()
|
||||
public ApiResult<List<GoodsPrice>> list(GoodsPriceParam param) {
|
||||
PageParam<GoodsPrice, GoodsPriceParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(goodsPriceService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(goodsPriceService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商品价格()")
|
||||
@GetMapping("/info-by-city/{goodsId}/{cityId}")
|
||||
public ApiResult<GoodsPrice> infoByCity(@PathVariable("goodsId") Integer goodsId, @PathVariable("cityId") Integer cityId) {
|
||||
return success(goodsPriceService.getByGoodsIdNCity(goodsId, cityId));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商品价格()")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<GoodsPrice> get(@PathVariable("id") Integer id) {
|
||||
return success(goodsPriceService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(goodsPriceService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商品价格()")
|
||||
@GetMapping("/by-goodsId-n-city/{id}")
|
||||
public ApiResult<GoodsPrice> getByGoodsIdNCity(@PathVariable("id") Integer id) {
|
||||
User loginUser = getLoginUser();
|
||||
return success(goodsPriceService.getByGoodsIdNCity(id, loginUser.getCityId()));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商品价格()")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody GoodsPrice goodsPrice) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
goodsPrice.setUserId(loginUser.getUserId());
|
||||
Area province = areaService.getParent(goodsPrice.getCity());
|
||||
goodsPrice.setProvince(province.getId());
|
||||
goodsPrice.setProvince(loginUser.getCityId());
|
||||
}
|
||||
if (goodsPriceService.save(goodsPrice)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商品价格()")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody GoodsPrice goodsPrice) {
|
||||
if (goodsPriceService.updateById(goodsPrice)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商品价格()")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (goodsPriceService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商品价格()")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<GoodsPrice> list) {
|
||||
if (goodsPriceService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商品价格()")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<GoodsPrice> batchParam) {
|
||||
if (batchParam.update(goodsPriceService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsPrice:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商品价格()")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsPriceService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +1,57 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.extra.qrcode.QrConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.apps.entity.BcAgent;
|
||||
import com.gxwebsoft.apps.entity.EquipmentGoods;
|
||||
import com.gxwebsoft.apps.entity.EquipmentOrderGoods;
|
||||
import com.gxwebsoft.apps.param.BcAgentParam;
|
||||
import com.gxwebsoft.apps.service.BcAgentService;
|
||||
import com.gxwebsoft.apps.service.EquipmentGoodsService;
|
||||
import com.gxwebsoft.apps.service.EquipmentOrderGoodsService;
|
||||
import com.gxwebsoft.apps.service.EquipmentService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.Area;
|
||||
import com.gxwebsoft.common.system.entity.FileRecord;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.common.system.service.FileRecordService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.UserReferee;
|
||||
import com.gxwebsoft.shop.constants.OrderConstants;
|
||||
import com.gxwebsoft.shop.entity.*;
|
||||
import com.gxwebsoft.shop.param.OrderGoodsParam;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import com.gxwebsoft.shop.service.OrderGoodsService;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.service.UserRefereeService;
|
||||
import com.gxwebsoft.shop.service.*;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
import com.gxwebsoft.vivo.entity.VivoFixStore;
|
||||
import com.gxwebsoft.vivo.entity.VivoStore;
|
||||
import com.gxwebsoft.vivo.service.VivoFixStoreService;
|
||||
import com.gxwebsoft.vivo.service.VivoStoreService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -53,59 +70,231 @@ public class OrderController extends BaseController {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private EquipmentGoodsService equipmentGoodsService;
|
||||
@Resource
|
||||
private EquipmentService equipmentService;
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
@Resource
|
||||
private EquipmentOrderGoodsService equipmentOrderGoodsService;
|
||||
private GoodsService goodsService;
|
||||
@Resource
|
||||
private UserRefereeService userRefereeService;
|
||||
private GoodsPriceService goodsPriceService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private BcAgentService bcAgentService;
|
||||
private VivoStoreService storeService;
|
||||
@Resource
|
||||
private VivoFixStoreService fixStoreService;
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
@Resource
|
||||
private OrderRefundService orderRefundService;
|
||||
@Resource
|
||||
private FileRecordService fileRecordService;
|
||||
|
||||
@Autowired
|
||||
private WxPayController wxPayController;
|
||||
|
||||
@Value("${config.upload-path}")
|
||||
private String uploadPath;
|
||||
|
||||
@Value("${config.server-url}")
|
||||
private String requestURL;
|
||||
|
||||
@PostMapping("/new")
|
||||
public ApiResult<?> addOrder(@RequestBody Order order) {
|
||||
User loginUser = getLoginUser();
|
||||
order.setUserId(loginUser.getUserId());
|
||||
order.setOrgId(loginUser.getOrganizationId());
|
||||
order.setOrderNo(makeOrderNumber(""));
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
GoodsPrice goodsPrice = goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId());
|
||||
order.setStoreId(loginUser.getStoreId());
|
||||
order.setCityId(loginUser.getCityId());
|
||||
BigDecimal goodsAmount = goods.getLinePriceMin();
|
||||
BigDecimal commission = BigDecimal.ZERO;
|
||||
if (goodsPrice != null) {
|
||||
if (loginUser.getUserLevel().equals(5) || loginUser.getUserLevel().equals(8)) {
|
||||
goodsAmount = goods.getGoodsPriceMin();
|
||||
}
|
||||
if (loginUser.getUserLevel().equals(3)) {
|
||||
if (goodsPrice.getLevel3commissionMode().equals(1)) {
|
||||
commission = goodsAmount.multiply(goodsPrice.getLevel3commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
} else {
|
||||
commission = goodsPrice.getLevel3commissionRate();
|
||||
}
|
||||
order.setCommission(commission);
|
||||
} else if (loginUser.getUserLevel().equals(4)) {
|
||||
if (goodsPrice.getLevel4commissionMode().equals(1)) {
|
||||
commission = goodsAmount.multiply(goodsPrice.getLevel4commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
} else {
|
||||
commission = goodsPrice.getLevel4commissionRate();
|
||||
}
|
||||
order.setCommission(commission);
|
||||
} else if (loginUser.getUserLevel().equals(5) || loginUser.getUserLevel().equals(8)) {
|
||||
commission = goodsAmount.multiply(goodsPrice.getLevel5commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
order.setCommission(commission);
|
||||
} else if (loginUser.getUserLevel().equals(6)) {
|
||||
if (goodsPrice.getLevel6commissionMode().equals(1)) {
|
||||
commission = goodsAmount.multiply(goodsPrice.getLevel6commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
} else {
|
||||
commission = goodsPrice.getLevel6commissionRate();
|
||||
}
|
||||
order.setCommission(commission);
|
||||
} else if (loginUser.getUserLevel().equals(7)) {
|
||||
if (goodsPrice.getLevel7commissionMode().equals(1)) {
|
||||
commission = goodsAmount.multiply(goodsPrice.getLevel7commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
} else {
|
||||
commission = goodsPrice.getLevel7commissionRate();
|
||||
}
|
||||
order.setCommission(commission);
|
||||
}
|
||||
// else if (loginUser.getUserLevel().equals(8)) {
|
||||
// commission = goodsAmount.multiply(goodsPrice.getLevel8commissionRate()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
// order.setCommission(commission);
|
||||
// }
|
||||
// if (loginUser.getUserLevel().equals(5) || loginUser.getUserLevel().equals(8)) {
|
||||
// if (loginUser.getFixStoreId() != null) {
|
||||
// BigDecimal fixStoreLeaderCommission = order.getCommission()
|
||||
// .multiply(goodsPrice.getFixStoreLeaderCommissionRate())
|
||||
// .divide(BigDecimal.valueOf(100), RoundingMode.HALF_UP);
|
||||
// order.setFixStoreLeaderCommission(fixStoreLeaderCommission);
|
||||
// }
|
||||
// }
|
||||
if (loginUser.getUserLevel().equals(5) || loginUser.getUserLevel().equals(8)) {
|
||||
order.setAgentCommission(BigDecimal.ZERO);
|
||||
} else {
|
||||
order.setAgentCommission(goodsAmount.subtract(goods.getCost()).subtract(commission));
|
||||
}
|
||||
}
|
||||
order.setTotalPrice(goodsAmount);
|
||||
if (loginUser.getUserLevel().equals(5) || loginUser.getUserLevel().equals(8)) {
|
||||
if (loginUser.getFixStoreId() != null) {
|
||||
order.setFixStoreId(loginUser.getFixStoreId());
|
||||
}
|
||||
}
|
||||
if (orderService.save(order)) {
|
||||
OrderGoods orderGoods = order.getOrderGoods();
|
||||
orderGoods.setOrderId(order.getOrderId());
|
||||
orderGoods.setUserId(getLoginUserId());
|
||||
orderGoodsService.save(orderGoods);
|
||||
return success("下单成功", order.getOrderId());
|
||||
}
|
||||
return fail("下单失败");
|
||||
}
|
||||
|
||||
@PostMapping("/update-info")
|
||||
public ApiResult<?> updateInfo(@RequestBody Order order) {
|
||||
return success(orderService.updateById(order));
|
||||
}
|
||||
|
||||
@PostMapping("/make-pay-qr")
|
||||
public ApiResult<?> makePayQr(@RequestBody Order order) {
|
||||
Order order1 = orderService.getById(order.getOrderId());
|
||||
Goods goods = goodsService.getById(order1.getGoodsId());
|
||||
return success(wxPayController.nativePay(order1.getOrderNo(),
|
||||
order1.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue(), goods.getGoodsName()));
|
||||
}
|
||||
|
||||
@PostMapping("/set-pay-voucher")
|
||||
public ApiResult<?> setPayVoucher(@RequestBody Order order) {
|
||||
order.setOrderStatus(OrderConstants.ORDER_STATUS_PAID);
|
||||
Order order1 = orderService.getById(order.getOrderId());
|
||||
order.setReceiptAmount(order1.getTotalAmount());
|
||||
if (orderService.updateById(order)) {
|
||||
orderService.updateIncome(order1);
|
||||
return success("更新成功");
|
||||
}
|
||||
return fail("更新失败");
|
||||
}
|
||||
|
||||
@PostMapping("/set-refund")
|
||||
public ApiResult<?> setRefund(@RequestBody Order order) {
|
||||
order.setOrderStatus(OrderConstants.ORDER_STATUS_REFUNDING);
|
||||
if (orderService.updateById(order)) {
|
||||
Order order1 = orderService.getById(order.getOrderId());
|
||||
OrderRefund orderRefund = new OrderRefund();
|
||||
orderRefund.setOrderId(order1.getOrderId());
|
||||
orderRefund.setOrderGoodsId(order1.getGoodsId());
|
||||
orderRefund.setRefundMoney(order1.getReceiptAmount());
|
||||
orderRefund.setTenantId(10049);
|
||||
orderRefundService.save(orderRefund);
|
||||
return success("申请成功,请等待审核");
|
||||
}
|
||||
return fail("更新失败");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/do-refund")
|
||||
public ApiResult<?> doRefund(@RequestBody Order order) {
|
||||
if (orderService.updateById(order)) {
|
||||
refund(order);
|
||||
return success("退款成功");
|
||||
}
|
||||
return fail("退款失败");
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public ApiResult<?> listForFront(@RequestBody OrderParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser.getUserLevel() < 3) {
|
||||
if (loginUser.getUserLevel().equals(1)) {
|
||||
param.setCityId(loginUser.getCityId());
|
||||
param.setFixStoreId(0);
|
||||
}
|
||||
} else {
|
||||
if (loginUser.getUserLevel().equals(8)) {
|
||||
VivoFixStore fixStore = fixStoreService.getByUserId(loginUser.getUserId());
|
||||
if (fixStore != null) {
|
||||
param.setFixStoreId(fixStore.getId());
|
||||
}
|
||||
} else {
|
||||
param.setUserId(getLoginUserId());
|
||||
}
|
||||
}
|
||||
List<Order> list = orderService.listRel(param);
|
||||
list.forEach(order -> {
|
||||
if (order.getStoreId() != null) order.setStore(storeService.getById(order.getStoreId()));
|
||||
if (order.getFixStoreId() != null) order.setFixStore(fixStoreService.getById(order.getFixStoreId()));
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
goods.setGoodsPrice(goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId()));
|
||||
order.setGoods(goods);
|
||||
order.setUser(userService.getById(order.getUserId()));
|
||||
});
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PostMapping("/info")
|
||||
public ApiResult<Order> info(@RequestBody OrderParam param) {
|
||||
Order order = orderService.getByIdRel(param.getOrderId());
|
||||
if (order != null) {
|
||||
if (order.getStoreId() != null) order.setStore(storeService.getById(order.getStoreId()));
|
||||
if (order.getFixStoreId() != null) order.setFixStore(fixStoreService.getById(order.getFixStore()));
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
|
||||
@PostMapping("/set-done")
|
||||
public ApiResult<Order> setDone(@RequestBody Order order) {
|
||||
order.setUseTime(DateUtil.date());
|
||||
orderService.updateById(order);
|
||||
return success(order);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询订单记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Order>> page(OrderParam param) {
|
||||
// 搜索条件
|
||||
if (getMerchantCode() != null) {
|
||||
param.setMerchantCode(getMerchantCode());
|
||||
@PostMapping("/page")
|
||||
public ApiResult<PageResult<Order>> page(@RequestBody OrderParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser.getUserLevel().equals(1)) {
|
||||
param.setCityId(loginUser.getCityId());
|
||||
}
|
||||
// 云芯威项目查询关联设备
|
||||
if(getTenantId().equals(6)){
|
||||
// 查询订单的关联商品
|
||||
List<Order> list = orderService.listRel(param);
|
||||
// 查询订单的设备
|
||||
for (Order order : list) {
|
||||
final OrderGoodsParam orderGoodsParam = new OrderGoodsParam();
|
||||
orderGoodsParam.setOrderId(order.getOrderId());
|
||||
order.setGoodsList(orderGoodsService.listRel(orderGoodsParam));
|
||||
order.setEquipmentGoods(equipmentOrderGoodsService.getOne(new LambdaQueryWrapper<EquipmentOrderGoods>().eq(EquipmentOrderGoods::getOrderId,order.getOrderId())));
|
||||
order.setEquipment(equipmentService.getById(order.getEquipmentId()));
|
||||
}
|
||||
PageParam<Order, OrderParam> page = new PageParam<>(param);
|
||||
return success(new PageResult<>(list, page.getTotal()));
|
||||
}
|
||||
// 贵港自然资源报餐
|
||||
if(getTenantId().equals(10048) && getAppId() != null){
|
||||
final BcAgentParam bcAgentParam = new BcAgentParam();
|
||||
bcAgentParam.setParentId(getLoginUserId());
|
||||
bcAgentParam.setLimit(100L);
|
||||
final PageResult<BcAgent> result = bcAgentService.pageRel(bcAgentParam);
|
||||
final Set<Integer> collect = result.getList().stream().map(BcAgent::getUserId).collect(Collectors.toSet());
|
||||
collect.add(getLoginUserId());
|
||||
param.setUserId(null);
|
||||
param.setUserIds(collect);
|
||||
return success(orderService.pageRel(param));
|
||||
}
|
||||
|
||||
// 使用关联查询
|
||||
return success(orderService.pageRel(param));
|
||||
Page<Order> list = orderService.getByPage(param);
|
||||
list.getRecords().forEach(order -> {
|
||||
if (order.getStoreId() != null) order.setStore(storeService.getById(order.getStoreId()));
|
||||
if (order.getFixStoreId() != null) order.setFixStore(fixStoreService.getById(order.getFixStore()));
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
order.setGoods(goods);
|
||||
order.setUser(userService.getById(order.getUserId()));
|
||||
});
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@@ -113,8 +302,12 @@ public class OrderController extends BaseController {
|
||||
@ApiOperation("查询全部订单记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Order>> list(OrderParam param) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser.getUserLevel().equals(1)) {
|
||||
param.setCityId(loginUser.getCityId());
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(orderService.listRel(param));
|
||||
return success(orderService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@@ -122,21 +315,21 @@ public class OrderController extends BaseController {
|
||||
@ApiOperation("按订单集查询")
|
||||
@PostMapping("/listByIds")
|
||||
public ApiResult<List<Order>> listByIds(@RequestBody List<Integer> orderIds) {
|
||||
System.out.println("按订单集查询 = " + orderIds);
|
||||
Integer userId = getLoginUserId();
|
||||
// 代报餐情况(未完成)
|
||||
final Order order = orderService.getById(orderIds.get(0));
|
||||
if (!order.getUserId().equals(getLoginUserId())) {
|
||||
userId = order.getUserId();
|
||||
final List<Order> list1 = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderId,orderIds).eq(Order::getUserId, userId).eq(Order::getPayStatus,PAY_STATUS_NO_PAY));
|
||||
final Set<Integer> collect = list1.stream().map(Order::getOrderId).collect(Collectors.toSet());
|
||||
return success(orderService.listByIds(collect));
|
||||
}
|
||||
System.out.println("按订单集查询 = " + orderIds);
|
||||
Integer userId = getLoginUserId();
|
||||
// 代报餐情况(未完成)
|
||||
final Order order = orderService.getById(orderIds.get(0));
|
||||
if (!order.getUserId().equals(getLoginUserId())) {
|
||||
userId = order.getUserId();
|
||||
final List<Order> list1 = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderId, orderIds).eq(Order::getUserId, userId).eq(Order::getPayStatus, PAY_STATUS_NO_PAY));
|
||||
final Set<Integer> collect = list1.stream().map(Order::getOrderId).collect(Collectors.toSet());
|
||||
return success(orderService.listByIds(collect));
|
||||
}
|
||||
|
||||
final List<Order> list1 = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getUserId, getLoginUserId()).eq(Order::getPayStatus,PAY_STATUS_NO_PAY));
|
||||
final List<Integer> collect = list1.stream().map(Order::getOrderId).collect(Collectors.toList());
|
||||
// 使用关联查询
|
||||
return success(orderService.listByIds(collect));
|
||||
final List<Order> list1 = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getUserId, getLoginUserId()).eq(Order::getPayStatus, PAY_STATUS_NO_PAY));
|
||||
final List<Integer> collect = list1.stream().map(Order::getOrderId).collect(Collectors.toList());
|
||||
// 使用关联查询
|
||||
return success(orderService.listByIds(collect));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@@ -144,14 +337,10 @@ public class OrderController extends BaseController {
|
||||
@ApiOperation("根据id查询订单记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Order> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
Order order = orderService.getByIdRel(id);
|
||||
// 云芯威关联设备查询
|
||||
if (!order.getGoodsId().equals(0) || !order.getEquipmentId().equals(0)) {
|
||||
order.setEquipmentGoods(equipmentOrderGoodsService.getOne(new LambdaQueryWrapper<EquipmentOrderGoods>().eq(EquipmentOrderGoods::getOrderId,order.getOrderId())));
|
||||
order.setEquipment(equipmentService.getById(order.getEquipmentId()));
|
||||
}
|
||||
return success(order);
|
||||
// 使用关联查询
|
||||
Order order = orderService.getByIdRel(id);
|
||||
|
||||
return success(order);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:save')")
|
||||
@@ -162,58 +351,14 @@ public class OrderController extends BaseController {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
order.setUserId(loginUser.getUserId());
|
||||
order.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (orderService.save(order)) {
|
||||
// 云芯威BMS
|
||||
if (order.getTenantId().equals(6)) {
|
||||
final EquipmentGoods eg = equipmentGoodsService.getById(order.getOrderSourceId());
|
||||
eg.setOrderId(order.getOrderId());
|
||||
// 添加订单商品
|
||||
final EquipmentOrderGoods oeg = new EquipmentOrderGoods();
|
||||
oeg.setOrderId(order.getOrderId());
|
||||
oeg.setGoodsName(eg.getGoodsName());
|
||||
oeg.setEquipmentCategory(eg.getEquipmentCategory());
|
||||
oeg.setImage(eg.getImage());
|
||||
oeg.setCategoryId(eg.getCategoryId());
|
||||
oeg.setBatteryModel(eg.getBatteryModel());
|
||||
oeg.setSellingPoint(eg.getSellingPoint());
|
||||
oeg.setStockTotal(eg.getStockTotal());
|
||||
oeg.setContent(eg.getContent());
|
||||
oeg.setBatteryPrice(eg.getBatteryPrice());
|
||||
oeg.setBatteryRent(eg.getBatteryRent());
|
||||
oeg.setBatteryInsurance(eg.getBatteryInsurance());
|
||||
oeg.setBatteryDeposit(eg.getBatteryDeposit());
|
||||
oeg.setDownPayment(eg.getDownPayment());
|
||||
oeg.setPeriods(eg.getPeriods());
|
||||
oeg.setRepayment(eg.getRepayment());
|
||||
oeg.setServiceCharges(eg.getServiceCharges());
|
||||
oeg.setPeriodsType(eg.getPeriodsType());
|
||||
oeg.setUserId(eg.getUserId());
|
||||
oeg.setComments(eg.getComments());
|
||||
oeg.setStatus(eg.getStatus());
|
||||
oeg.setMerchantCode(eg.getMerchantCode());
|
||||
oeg.setTenantId(eg.getTenantId());
|
||||
|
||||
equipmentOrderGoodsService.saveOrUpdate(oeg);
|
||||
|
||||
// 添加推荐人关系
|
||||
if (order.getDealerId() != null) {
|
||||
final User dealer = userService.getById(order.getDealerId());
|
||||
if(dealer == null){
|
||||
return fail("推荐人的用户ID不存在");
|
||||
}
|
||||
final UserReferee referee = new UserReferee();
|
||||
referee.setDealerId(order.getDealerId());
|
||||
referee.setUserId(getLoginUserId());
|
||||
userRefereeService.save(referee);
|
||||
// 是否存入星期值
|
||||
if (order.getDeliveryTime() != null) {
|
||||
order.setWeek(DateUtil.dayOfWeek(order.getDeliveryTime()) - 1);
|
||||
}
|
||||
}
|
||||
// 是否存入星期值
|
||||
if(order.getDeliveryTime() != null){
|
||||
order.setWeek(DateUtil.dayOfWeek(order.getDeliveryTime()) - 1);
|
||||
}
|
||||
return success("添加成功",order);
|
||||
return success("添加成功", order);
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
@@ -224,11 +369,91 @@ public class OrderController extends BaseController {
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Order order) {
|
||||
if (orderService.updateById(order)) {
|
||||
refund(order);
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
private void refund(Order order) {
|
||||
if (order.getOrderStatus().equals(OrderConstants.ORDER_STATUS_REFUND_SUCCESS)) {
|
||||
OrderRefund orderRefund = orderRefundService.getByOrderId(order.getOrderId());
|
||||
orderRefund.setAuditStatus(10);
|
||||
|
||||
Order order1 = orderService.getById(order.getOrderId());
|
||||
User user = userService.getById(order1.getUserId());
|
||||
user.setBalance(user.getBalance().subtract(order1.getCommission()));
|
||||
user.setTotalIncome(user.getTotalIncome().subtract(order1.getCommission()));
|
||||
userService.updateById(user);
|
||||
userBalanceLogService.save(
|
||||
new UserBalanceLog() {{
|
||||
setOrderId(order1.getOrderId());
|
||||
setUserId(user.getUserId());
|
||||
setScene(1);
|
||||
setMoney(order1.getCommission());
|
||||
setBalance(user.getBalance());
|
||||
setTenantId(10049);
|
||||
setCreateTime(DateUtil.date());
|
||||
setRemark("订单:" + order1.getOrderNo() + "退款,收回返利");
|
||||
}}
|
||||
);
|
||||
|
||||
// 售后门店
|
||||
// if (order1.getFixStoreId() != null
|
||||
// && order1.getFixStoreLeaderCommission() != null
|
||||
// && order1.getFixStoreLeaderCommission().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// VivoFixStore vivoFixStore = fixStoreService.getById(order1.getFixStoreId());
|
||||
// User fixStoreLeader = userService.getById(vivoFixStore.getUserId());
|
||||
// fixStoreLeader.setBalance(fixStoreLeader.getBalance().subtract(order1.getFixStoreLeaderCommission()));
|
||||
// fixStoreLeader.setTotalIncome(fixStoreLeader.getTotalIncome().subtract(order1.getFixStoreLeaderCommission()));
|
||||
// userService.updateById(fixStoreLeader);
|
||||
// userBalanceLogService.save(
|
||||
// new UserBalanceLog() {{
|
||||
// setOrderId(order1.getOrderId());
|
||||
// setUserId(fixStoreLeader.getUserId());
|
||||
// setScene(1);
|
||||
// setMoney(order1.getFixStoreLeaderCommission());
|
||||
// setBalance(fixStoreLeader.getBalance());
|
||||
// setTenantId(10049);
|
||||
// setCreateTime(DateUtil.date());
|
||||
// setRemark("订单:" + order1.getOrderNo() + "退款,收回店长门店返利");
|
||||
// }}
|
||||
// );
|
||||
// }
|
||||
|
||||
User cityAgent = userService.getCityAgent(order1.getCityId());
|
||||
if (cityAgent != null && order1.getAgentCommission() != null && order1.getAgentCommission().compareTo(BigDecimal.ZERO) > 0) {
|
||||
cityAgent.setBalance(cityAgent.getBalance().subtract(order1.getAgentCommission()));
|
||||
cityAgent.setTotalIncome(cityAgent.getTotalIncome().subtract(order1.getAgentCommission()));
|
||||
userService.updateById(cityAgent);
|
||||
userBalanceLogService.save(
|
||||
new UserBalanceLog() {{
|
||||
setOrderId(order1.getOrderId());
|
||||
setUserId(cityAgent.getUserId());
|
||||
setScene(1);
|
||||
setMoney(order1.getAgentCommission());
|
||||
setBalance(cityAgent.getBalance());
|
||||
setTenantId(10049);
|
||||
setCreateTime(DateUtil.date());
|
||||
setRemark("订单:" + order1.getOrderNo() + "退款,收回区域返利");
|
||||
}}
|
||||
);
|
||||
}
|
||||
|
||||
if (order1.getPayMethod().equals(OrderConstants.ORDER_PAY_METHOD_WECHAT.toString())) {
|
||||
orderRefund.setOrder(orderService.getById(order1.getOrderId()));
|
||||
wxPayController.refund(orderRefund);
|
||||
} else {
|
||||
orderRefund.setRefundStatus(1);
|
||||
}
|
||||
orderRefundService.updateById(orderRefund);
|
||||
} else if (order.getOrderStatus().equals(OrderConstants.ORDER_STATUS_REFUND_FAIL)) {
|
||||
OrderRefund orderRefund = orderRefundService.getByOrderId(order.getOrderId());
|
||||
orderRefund.setAuditStatus(20);
|
||||
orderRefundService.updateById(orderRefund);
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除订单记录表")
|
||||
@@ -275,46 +500,116 @@ public class OrderController extends BaseController {
|
||||
|
||||
@ApiOperation("支付成功")
|
||||
@PostMapping("/setPayStatus")
|
||||
public ApiResult<?> setPayStatus(@RequestBody Order order){
|
||||
if (orderService.updateById(order)) {
|
||||
return success("设置成功");
|
||||
}
|
||||
return fail("设置失败");
|
||||
public ApiResult<?> setPayStatus(@RequestBody Order order) {
|
||||
if (orderService.updateById(order)) {
|
||||
return success("设置成功");
|
||||
}
|
||||
return fail("设置失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("生成核销付款码(二维码)")
|
||||
@GetMapping("/generateQrCode")
|
||||
public ApiResult<?> generateQrCode(OrderParam param) throws IOException {
|
||||
// 查询当天的报餐信息
|
||||
param.setUserId(getLoginUserId());
|
||||
param.setDeliveryTime(DateUtil.beginOfDay(DateUtil.date()).toString());
|
||||
param.setOrderStatus(ORDER_STATUS_DOING);
|
||||
param.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
param.setDeleted(0);
|
||||
final List<Order> list = orderService.listRel(param);
|
||||
if(list.size() == 0){
|
||||
return fail("今日无报餐记录");
|
||||
}
|
||||
final Order order = list.get(0);
|
||||
// LOGO URL地址
|
||||
String logoUrl = "https://file.wsdns.cn/20230430/6fa31aca3b0d47af98a149cf2dd26a4f.jpeg";
|
||||
// 二维码生成图片保存路径
|
||||
String filePath = "/www/wwwroot/file.ws/file/qrcode/" + getLoginUserId() + "/payQrCode.jpg";
|
||||
// 二维码访问路径
|
||||
String qrcodeUrl = "https://file.gxwebsoft.com/qrcode/" + getLoginUserId() + "/payQrCode.jpg" + "?v=" + DateUtil.current();
|
||||
// 二维码内容
|
||||
final String orderNo = order.getOrderNo().toString();
|
||||
// 将URL转为BufferedImage
|
||||
BufferedImage bufferedImage = ImageIO.read(new URL(logoUrl));
|
||||
// 生成二维码
|
||||
QrConfig config = new QrConfig(300, 300);
|
||||
// 设置边距,既二维码和背景之间的边距
|
||||
config.setMargin(1);
|
||||
// 附带小logo
|
||||
config.setImg(bufferedImage);
|
||||
QrCodeUtil.generate(orderNo, config, FileUtil.file(filePath));
|
||||
return success("请求成功",qrcodeUrl);
|
||||
@ApiOperation("导出")
|
||||
@PostMapping("/export")
|
||||
public ApiResult<?> export(@RequestBody OrderParam param, HttpServletRequest request) throws IOException {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser.getUserLevel().equals(1)) {
|
||||
param.setCityId(loginUser.getCityId());
|
||||
}
|
||||
String filename = "file/excel/订单表" + new Date().getTime() + ".xls";
|
||||
String path = uploadPath + filename;
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
//创建工作表单
|
||||
HSSFSheet sheet = workbook.createSheet();
|
||||
List<Order> orderList = orderService.listRel(param);
|
||||
HSSFRow row = sheet.createRow(0);
|
||||
row.createCell(0).setCellValue("订单号");
|
||||
row.createCell(1).setCellValue("下单人手机号");
|
||||
row.createCell(2).setCellValue("购买的产品");
|
||||
row.createCell(3).setCellValue("IMEI");
|
||||
row.createCell(4).setCellValue("型号");
|
||||
row.createCell(5).setCellValue("系列");
|
||||
row.createCell(6).setCellValue("上报人工号");
|
||||
row.createCell(7).setCellValue("上报人姓名");
|
||||
row.createCell(8).setCellValue("激活状态");
|
||||
row.createCell(9).setCellValue("激活时间");
|
||||
row.createCell(10).setCellValue("门店");
|
||||
row.createCell(11).setCellValue("二级区域名称");
|
||||
row.createCell(12).setCellValue("零售商名称");
|
||||
row.createCell(13).setCellValue("好/坏机");
|
||||
row.createCell(14).setCellValue("下单人信息");
|
||||
row.createCell(15).setCellValue("下单门店信息");
|
||||
row.createCell(16).setCellValue("有效期开始时间");
|
||||
row.createCell(17).setCellValue("有效期结束时间");
|
||||
row.createCell(18).setCellValue("订单金额");
|
||||
row.createCell(19).setCellValue("成本价");
|
||||
row.createCell(20).setCellValue("下单人佣金");
|
||||
row.createCell(21).setCellValue("区域代理佣金");
|
||||
row.createCell(22).setCellValue("订单状态");
|
||||
row.createCell(23).setCellValue("下单时间");
|
||||
int rowNum = 1;
|
||||
for (Order order : orderList) {
|
||||
//订单状态(0已取消1待支付2已支付3已结束4退款审核中5退款成功6退款失败)
|
||||
String orderStatus = "";
|
||||
HSSFRow orderRow = sheet.createRow(rowNum);
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
String storeName = "";
|
||||
if (order.getStoreId() != null) {
|
||||
VivoStore store = storeService.getById(order.getStoreId());
|
||||
if (store != null) storeName = store.getName();
|
||||
}
|
||||
if (order.getFixStoreId() != null) {
|
||||
VivoFixStore store = fixStoreService.getById(order.getFixStoreId());
|
||||
if (store != null) storeName = store.getName();
|
||||
}
|
||||
User user = userService.getById(order.getUserId());
|
||||
orderRow.createCell(0).setCellValue(order.getOrderNo());
|
||||
orderRow.createCell(1).setCellValue(user.getPhone());
|
||||
orderRow.createCell(2).setCellValue(goods.getGoodsName());
|
||||
orderRow.createCell(3).setCellValue(order.getImei());
|
||||
orderRow.createCell(4).setCellValue(order.getSkuName());
|
||||
orderRow.createCell(5).setCellValue(order.getModelName());
|
||||
orderRow.createCell(6).setCellValue(order.getSellerCode());
|
||||
orderRow.createCell(7).setCellValue(order.getSellerName());
|
||||
orderRow.createCell(8).setCellValue(order.getActiveState());
|
||||
orderRow.createCell(9).setCellValue(order.getActiveDate());
|
||||
orderRow.createCell(10).setCellValue(order.getStoreName());
|
||||
orderRow.createCell(11).setCellValue(order.getSecondAreaName());
|
||||
orderRow.createCell(12).setCellValue(order.getRetailerName());
|
||||
orderRow.createCell(13).setCellValue(!order.getGoodOrBad().equals("undefined") ? order.getGoodOrBad() : "");
|
||||
orderRow.createCell(14).setCellValue(user.getRealName());
|
||||
orderRow.createCell(15).setCellValue(storeName);
|
||||
orderRow.createCell(16).setCellValue(DateUtil.formatDateTime(order.getStartTime()) + " ");
|
||||
orderRow.createCell(17).setCellValue(DateUtil.formatDateTime(order.getExpirationTime()) + " ");
|
||||
orderRow.createCell(18).setCellValue(order.getTotalPrice().toString());
|
||||
orderRow.createCell(19).setCellValue(goods.getCost().toString());
|
||||
orderRow.createCell(20).setCellValue(order.getCommission() != null ? order.getCommission().toString() : "0");
|
||||
orderRow.createCell(21).setCellValue(order.getAgentCommission() != null ? order.getAgentCommission().toString() : "0");
|
||||
orderRow.createCell(22).setCellValue(OrderConstants.ORDER_STATUS_MAP.get(order.getOrderStatus()));
|
||||
orderRow.createCell(23).setCellValue(DateUtil.formatDateTime(order.getCreateTime()) + " ");
|
||||
rowNum++;
|
||||
}
|
||||
FileOutputStream output = new FileOutputStream(path);
|
||||
workbook.write(output);
|
||||
output.flush();
|
||||
|
||||
FileRecord result = new FileRecord();
|
||||
result.setCreateUserId(getLoginUserId());
|
||||
result.setName(filename);
|
||||
result.setPath(path);
|
||||
result.setUrl(requestURL + "/" + filename);
|
||||
// result.setMerchantCode(getMerchantCode());
|
||||
fileRecordService.save(result);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
protected void task() {
|
||||
// 1小时未支付的单
|
||||
orderService.update(
|
||||
new UpdateWrapper<Order>().eq("order_status", 1)
|
||||
.lt("create_time", DateUtil.offsetHour(new Date(), -1))
|
||||
.set("order_status", 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class OrderGoodsController extends BaseController {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
orderGoods.setUserId(loginUser.getUserId());
|
||||
orderGoods.setMerchantCode(getMerchantCode());
|
||||
// orderGoods.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (orderGoodsService.save(orderGoods)) {
|
||||
return success("添加成功");
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.apps.entity.Equipment;
|
||||
import com.gxwebsoft.apps.service.EquipmentService;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
@@ -38,8 +36,6 @@ public class OrderRefundController extends BaseController {
|
||||
private OrderRefundService orderRefundService;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private EquipmentService equipmentService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefund:list')")
|
||||
@OperationLog
|
||||
@@ -90,15 +86,6 @@ public class OrderRefundController extends BaseController {
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody OrderRefund orderRefund) {
|
||||
if (orderRefundService.updateById(orderRefund)) {
|
||||
if(orderRefund.getTenantId().equals(6)){
|
||||
final Integer orderId = orderRefund.getOrderId();
|
||||
final Order order = orderService.getById(orderId);
|
||||
System.out.println("order = " + order);
|
||||
order.setReceiptStatus(RECEIPT_STATUS_RETURN);
|
||||
final Equipment equipment = equipmentService.getById(order.getEquipmentId());
|
||||
equipment.setUserId(0);
|
||||
equipmentService.updateById(equipment);
|
||||
}
|
||||
return success("操作成功");
|
||||
}
|
||||
return fail("退租失败");
|
||||
|
||||
@@ -2,24 +2,10 @@ package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayConstants;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.internal.util.AlipayEncrypt;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.alipay.api.request.AlipayTradeCreateRequest;
|
||||
import com.alipay.api.request.AlipayTradeQueryRequest;
|
||||
import com.alipay.api.response.AlipayTradeCreateResponse;
|
||||
import com.alipay.api.response.AlipayTradeQueryResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.apps.entity.BcTemporary;
|
||||
import com.gxwebsoft.apps.param.BcTemporaryParam;
|
||||
import com.gxwebsoft.apps.service.BcTemporaryService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.utils.AlipayConfigUtil;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.OperationRecordService;
|
||||
@@ -44,7 +30,6 @@ import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.BalanceConstants.BALANCE_USE;
|
||||
import static com.gxwebsoft.common.core.constants.OrderConstants.*;
|
||||
@@ -72,13 +57,9 @@ public class PaymentController extends BaseController {
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
@Resource
|
||||
private AlipayConfigUtil alipayConfig;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
@Resource
|
||||
private BcTemporaryService bcTemporaryService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:payment:list')")
|
||||
@ApiOperation("分页查询商城支付方式记录表")
|
||||
@@ -179,157 +160,11 @@ public class PaymentController extends BaseController {
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("支付宝手机号码")
|
||||
@PostMapping("/getPhoneNumber")
|
||||
public ApiResult<?> getPhoneNumber(@RequestBody Map<String, String> params) {
|
||||
final String encryptedData = params.get("encryptedData");
|
||||
final String tenantId = params.get("tenantId");
|
||||
// 支付宝配置信息
|
||||
JSONObject config = alipayConfig.payment(Integer.valueOf(tenantId));
|
||||
|
||||
//1. 获取验签和解密所需要的参数
|
||||
JSONObject jsonObject =JSONObject.parseObject(encryptedData);
|
||||
String content = jsonObject.getString("response");
|
||||
String sign = jsonObject.getString("sign");
|
||||
String signType = "RSA2";
|
||||
String charset = "UTF-8";
|
||||
String encryptType = "AES";
|
||||
String alipayCertPublicKey = pathConfig.getUploadPath() + "file" + config.getString("alipayCertPublicKey");
|
||||
boolean isDataEncrypted = !content.startsWith("{");
|
||||
boolean signVerified = false;
|
||||
//2. 验签
|
||||
String signContent = content;
|
||||
String signVeriKey = ""; // 支付宝公钥
|
||||
String decryptKey = config.getString("decryptKey"); // 加解密密钥
|
||||
// System.out.println("decryptKey = " + decryptKey);
|
||||
// System.out.println(content);
|
||||
// System.out.println(sign);
|
||||
// System.out.println(alipayCertPublicKey);
|
||||
// System.out.println(charset);
|
||||
// System.out.println(signType);
|
||||
// System.out.println(isDataEncrypted);
|
||||
if (isDataEncrypted) {
|
||||
signContent = "\"" + signContent + "\"";
|
||||
} try {
|
||||
//验签方法
|
||||
signVerified = AlipaySignature.rsaCertCheck(signContent, sign, alipayCertPublicKey, charset, signType);
|
||||
} catch (AlipayApiException e) {
|
||||
// 验签异常, 日志
|
||||
} if (!signVerified) {
|
||||
//验签不通过(异常或者报文被篡改),终止流程(不需要做解密)
|
||||
return fail("验签失败");
|
||||
}
|
||||
//3. 解密
|
||||
String plainData = null;
|
||||
if (isDataEncrypted) {
|
||||
try {
|
||||
plainData = AlipayEncrypt.decryptContent(content, encryptType, decryptKey, charset);
|
||||
} catch (AlipayApiException e) {
|
||||
//解密异常, 记录日志
|
||||
return fail("解密异常");
|
||||
}} else {
|
||||
plainData = content;
|
||||
}
|
||||
return success("获取成功",plainData);
|
||||
}
|
||||
|
||||
@ApiModelProperty("支付宝小程序支付")
|
||||
@GetMapping("/mp-alipay/{id}")
|
||||
public ApiResult<?> mpAlipay(@PathVariable("id") Integer id) throws AlipayApiException {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 订单数据
|
||||
Order order = orderService.getByIdRel(id);
|
||||
// 实例化客户端
|
||||
DefaultAlipayClient alipayClient = alipayConfig.alipayClient(order.getTenantId());
|
||||
try {
|
||||
AlipayTradeCreateRequest request = new AlipayTradeCreateRequest();
|
||||
// 配置公共请求参数
|
||||
request.setNotifyUrl(pathConfig.getServerUrl() + "/shop/payment/mp-alipay/notify");
|
||||
// request.setNotifyUrl("https://454k72r798.goho.co/api/shop/payment/mp-alipay/notify");
|
||||
request.setReturnUrl(null);
|
||||
// 配置业务参数
|
||||
JSONObject bizContent = new JSONObject();
|
||||
System.out.println("bizContent = " + order);
|
||||
bizContent.put("out_trade_no", order.getOrderNo());
|
||||
bizContent.put("total_amount", order.getPayPrice());
|
||||
bizContent.put("subject", order.getMerchantName());
|
||||
// 拿不到手机号码??
|
||||
bizContent.put("buyer_id", userOauthService.getOauthIdByUserId(order.getUserId(), "MP-ALIPAY"));
|
||||
request.setBizContent(bizContent.toString());
|
||||
//SDK 已经封装掉了公共参数,这里只需要传入业务参数。
|
||||
AlipayTradeCreateResponse response = alipayClient.certificateExecute(request);
|
||||
String trade_no = response.getTradeNo();// 获取返回的tradeNO。
|
||||
return success("支付成功", trade_no);
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiModelProperty("异步通知")
|
||||
@OperationLog
|
||||
@PostMapping("/mp-alipay/notify")
|
||||
public String alipayNotify(@RequestParam Map<String, String> params) throws AlipayApiException {
|
||||
System.out.println("异步处理>>>>");
|
||||
System.out.println("params = " + params);
|
||||
String outTradeNo = params.get("out_trade_no");
|
||||
Order order = orderService.getByOutTradeNo(outTradeNo);
|
||||
if(order == null){
|
||||
throw new BusinessException("订单不存在");
|
||||
}
|
||||
final JSONObject config = alipayConfig.payment(order.getTenantId());
|
||||
// 生成环境证书路径
|
||||
String alipayCertPublicKey = pathConfig.getUploadPath() + "file" + config.getString("alipayCertPublicKey");
|
||||
// TODO 验签成功后,按照支付结果异步通知中的描述,对支付结果中的业务内容进行二次校验,校验成功后在response中返回success并继续商户自身业务处理,校验失败返回failure
|
||||
boolean flag = AlipaySignature.rsaCertCheckV1(params, alipayCertPublicKey, AlipayConstants.CHARSET_UTF8, AlipayConstants.SIGN_TYPE_RSA2);
|
||||
System.out.println("flag>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
System.out.println(flag);
|
||||
// 处理订单业务
|
||||
if (flag) {
|
||||
final String tradeStatus = params.get("trade_status");
|
||||
final String receipt_amount = params.get("receipt_amount");
|
||||
final String payPrice = order.getPayPrice().toString();
|
||||
final String trade_no = params.get("trade_no");
|
||||
final String subject = params.get("subject");
|
||||
|
||||
// 1. 验证appId是否一致
|
||||
final String app_id = params.get("app_id");
|
||||
if(!config.getString("alipayAppId").equals(app_id)){
|
||||
System.out.println("支付宝appId不一致 = " + app_id);
|
||||
throw new BusinessException("支付宝appId不一致");
|
||||
}
|
||||
// 2. 订单金额
|
||||
if(!payPrice.equals(receipt_amount)){
|
||||
System.out.println("订单金额是不一致 = " + receipt_amount);
|
||||
throw new BusinessException("订单金额是不一致");
|
||||
}
|
||||
// 3. 判断交易状态
|
||||
if(!"TRADE_SUCCESS".equals(tradeStatus)){
|
||||
System.out.println("支付失败 = " + tradeStatus);
|
||||
throw new BusinessException("支付失败");
|
||||
}
|
||||
// 4. 修改支付状态
|
||||
order.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
order.setPayMethod(PAY_METHOD_ALIPAY);
|
||||
order.setReceiptAmount(new BigDecimal(receipt_amount));
|
||||
order.setPayTime(DateUtil.date());
|
||||
order.setTradeId(trade_no);
|
||||
order.setSubject(subject);
|
||||
System.out.println("order2 = " + order);
|
||||
final boolean b = orderService.updateByIdRel(order);
|
||||
System.out.println("bsss = " + b);
|
||||
return "success";
|
||||
}
|
||||
// TODO 验签失败则记录异常日志,并在response中返回failure.
|
||||
return "failure";
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiModelProperty("余额支付")
|
||||
@GetMapping("/balance/{id}")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public ApiResult<?> balance(@PathVariable("id") Integer id) throws AlipayApiException {
|
||||
public ApiResult<?> balance(@PathVariable("id") Integer id){
|
||||
// 1. 验证签名
|
||||
isCheckSign();
|
||||
// 订单数据
|
||||
@@ -385,15 +220,7 @@ public class PaymentController extends BaseController {
|
||||
order.setExpirationTime(nextMonthTime);
|
||||
orderService.updateById(order);
|
||||
}
|
||||
// 6. 是否是临时报餐
|
||||
final BcTemporaryParam bcTemporaryParam = new BcTemporaryParam();
|
||||
bcTemporaryParam.setUserId(getLoginUserId());
|
||||
bcTemporaryParam.setApplyStatus(1);
|
||||
final List<BcTemporary> bcTemporaries = bcTemporaryService.listRel(bcTemporaryParam);
|
||||
bcTemporaries.forEach(b -> {
|
||||
b.setStatus(1);
|
||||
bcTemporaryService.updateById(b);
|
||||
});
|
||||
|
||||
return success("支付成功",user);
|
||||
}
|
||||
|
||||
@@ -401,7 +228,7 @@ public class PaymentController extends BaseController {
|
||||
@ApiModelProperty("余额支付批量")
|
||||
@PostMapping("/balanceBatch")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public ApiResult<?> balanceBatch(@RequestBody List<Integer> orderIds) throws AlipayApiException {
|
||||
public ApiResult<?> balanceBatch(@RequestBody List<Integer> orderIds) {
|
||||
// 1. 验证签名
|
||||
isCheckSign();
|
||||
// 订单数据
|
||||
@@ -461,79 +288,8 @@ public class PaymentController extends BaseController {
|
||||
d.setExpirationTime(nextMonthTime);
|
||||
orderService.updateById(d);
|
||||
}
|
||||
// 6. 是否是临时报餐
|
||||
final BcTemporaryParam bcTemporaryParam = new BcTemporaryParam();
|
||||
bcTemporaryParam.setUserId(getLoginUserId());
|
||||
bcTemporaryParam.setApplyStatus(1);
|
||||
final List<BcTemporary> bcTemporaries = bcTemporaryService.listRel(bcTemporaryParam);
|
||||
bcTemporaries.forEach(b -> {
|
||||
b.setStatus(1);
|
||||
bcTemporaryService.updateById(b);
|
||||
});
|
||||
});
|
||||
return success("支付成功",sb);
|
||||
}
|
||||
|
||||
@ApiModelProperty("统一收单交易查询")
|
||||
@GetMapping("/mp-alipay/query/{id}")
|
||||
public ApiResult<?> query(@PathVariable("id") Integer id) throws AlipayApiException {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 订单数据
|
||||
Order order = orderService.getByIdRel(id);
|
||||
// 实例化客户端
|
||||
DefaultAlipayClient alipayClient = alipayConfig.alipayClient(order.getTenantId());
|
||||
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
|
||||
JSONObject bizContent = new JSONObject();
|
||||
bizContent.put("out_trade_no", order.getOrderNo());
|
||||
request.setBizContent(bizContent.toString());
|
||||
AlipayTradeQueryResponse response = alipayClient.certificateExecute(request);
|
||||
if(response.isSuccess()){
|
||||
System.out.println("调用成功");
|
||||
orderService.paySuccess(response);
|
||||
} else {
|
||||
System.out.println("调用失败");
|
||||
}
|
||||
return success("调用成功",response);
|
||||
}
|
||||
|
||||
@ApiModelProperty("测试")
|
||||
@GetMapping("/mp-alipay/test")
|
||||
public String test() {
|
||||
System.out.println("开始>>>>>");
|
||||
Order order = orderService.getByOutTradeNo("2023213225911618");
|
||||
System.out.println("order = " + order);
|
||||
order.setPayPrice(new BigDecimal("0.11"));
|
||||
order.setTotalPrice(new BigDecimal("0.11"));
|
||||
order.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
final boolean b = orderService.updateByIdRel(order);
|
||||
System.out.println("b = " + b);
|
||||
|
||||
// params.put("gmt_create", "2022-12-16 21:32:33");
|
||||
// params.put("charset", "UTF-8");
|
||||
// params.put("seller_email", "zhu115289@163.com");
|
||||
// params.put("subject", "测试商品");
|
||||
// params.put("buyer_id", "2088202959044205");
|
||||
// params.put("invoice_amount", "0.01");
|
||||
// params.put("notify_id", "2022121601222213308044201435873270");
|
||||
// params.put("fund_bill_list", "");
|
||||
// params.put("notify_type", "trade_status_sync");
|
||||
// params.put("trade_status", "TRADE_SUCCESS");
|
||||
// params.put("receipt_amount", "0.01");
|
||||
// params.put("buyer_pay_amount", "0.01");
|
||||
// params.put("app_id", "2021003156628508");
|
||||
// params.put("seller_id", "2088431805524422");
|
||||
// params.put("gmt_payment", "2022-12-16 21:33:07");
|
||||
// params.put("notify_time", "2022-12-16 21:33:09");
|
||||
// params.put("version", "1.0");
|
||||
// params.put("out_trade_no", "20221116205303366");
|
||||
// params.put("total_amount", "0.01");
|
||||
// params.put("trade_no", "2022121622001444201411215463");
|
||||
// params.put("auth_app_id", "2021003156628508");
|
||||
// params.put("buyer_logon_id", "ip1***@163.com");
|
||||
// params.put("point_amount", "0.00");
|
||||
// // 处理订单业务
|
||||
// orderService.paySuccess(params);
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,11 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayConstants;
|
||||
import com.alipay.api.CertAlipayRequest;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.internal.util.AlipayEncrypt;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.alipay.api.request.AlipayTradeCreateRequest;
|
||||
import com.alipay.api.response.AlipayTradeCreateResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.service.OperationRecordService;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.Payment;
|
||||
import com.gxwebsoft.shop.param.PaymentParam;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.service.PaymentService;
|
||||
import com.gxwebsoft.shop.service.UserOauthService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 定时任务
|
||||
@@ -48,16 +20,4 @@ public class SchedulingController extends BaseController {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
// /**
|
||||
// * 删除失效订单
|
||||
// */
|
||||
// @Scheduled(cron="0 0 */1 * * ?")
|
||||
// public void reportCurrentTime() {
|
||||
// System.out.println("定时任务开始 = " + new Date());
|
||||
// boolean remove = orderService.remove(new LambdaQueryWrapper<Order>()
|
||||
// .lt(Order::getExpirationTime, new Date())
|
||||
// .eq(Order::getPayStatus, 10)
|
||||
// .eq(Order::getOrderStatus, 10));
|
||||
// System.out.println("remove = " + remove);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.FileRecord;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.FileRecordService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.constants.OrderConstants;
|
||||
import com.gxwebsoft.shop.entity.Goods;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import com.gxwebsoft.shop.service.GoodsPriceService;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.service.UserBalanceLogService;
|
||||
import com.gxwebsoft.shop.entity.UserBalanceLog;
|
||||
import com.gxwebsoft.shop.param.UserBalanceLogParam;
|
||||
@@ -10,12 +21,24 @@ import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.vivo.entity.VivoFixStore;
|
||||
import com.gxwebsoft.vivo.entity.VivoStore;
|
||||
import com.gxwebsoft.vivo.service.VivoFixStoreService;
|
||||
import com.gxwebsoft.vivo.service.VivoStoreService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -30,14 +53,62 @@ import java.util.List;
|
||||
public class UserBalanceLogController extends BaseController {
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private VivoFixStoreService fixStoreService;
|
||||
@Resource
|
||||
private VivoStoreService storeService;
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Resource
|
||||
private GoodsPriceService goodsPriceService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private FileRecordService fileRecordService;
|
||||
|
||||
@Value("${config.upload-path}")
|
||||
private String uploadPath;
|
||||
|
||||
@Value("${config.server-url}")
|
||||
private String requestURL;
|
||||
|
||||
@PostMapping("/list")
|
||||
public ApiResult<List<UserBalanceLog>> listForFront(@RequestBody UserBalanceLogParam param) {
|
||||
// 使用关联查询
|
||||
User loginUser = getLoginUser();
|
||||
param.setUserId(getLoginUserId());
|
||||
List<UserBalanceLog> userBalanceLogList = userBalanceLogService.listRel(param);
|
||||
userBalanceLogList.forEach(userBalanceLog -> {
|
||||
Order order = orderService.getByIdRel(userBalanceLog.getOrderId());
|
||||
if (order.getStoreId() != null && order.getStoreId() != 0) {
|
||||
VivoStore store = storeService.getById(order.getStoreId());
|
||||
if (store != null) order.setStore(store);
|
||||
}
|
||||
if (order.getFixStoreId() != null && order.getFixStoreId() != 0) {
|
||||
VivoFixStore fixStore = fixStoreService.getById(order.getFixStoreId());
|
||||
if (fixStore != null) order.setFixStore(fixStore);
|
||||
}
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
goods.setGoodsPrice(goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId()));
|
||||
order.setGoods(goods);
|
||||
userBalanceLog.setOrder(order);
|
||||
});
|
||||
return success(userBalanceLogList);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询用户余额变动明细表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserBalanceLog>> page(UserBalanceLogParam param) {
|
||||
PageResult<UserBalanceLog> list = userBalanceLogService.pageRel(param);
|
||||
list.getList().forEach(userBalanceLog -> {
|
||||
userBalanceLog.setUser(userService.getByIdRel(userBalanceLog.getUserId()));
|
||||
});
|
||||
// 使用关联查询
|
||||
return success(userBalanceLogService.pageRel(param));
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:list')")
|
||||
@@ -70,8 +141,8 @@ public class UserBalanceLogController extends BaseController {
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userBalanceLog.setUserId(loginUser.getUserId());
|
||||
userBalanceLog.setMerchantCode(getMerchantCode());
|
||||
userBalanceLog.setUserId(loginUser.getUserId());
|
||||
// userBalanceLog.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (userBalanceLogService.save(userBalanceLog)) {
|
||||
return success("添加成功");
|
||||
@@ -134,4 +205,53 @@ public class UserBalanceLogController extends BaseController {
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("导出")
|
||||
@PostMapping("/export")
|
||||
public ApiResult<?> export(@RequestBody UserBalanceLogParam param, HttpServletRequest request) throws IOException {
|
||||
User loginUser = getLoginUser();
|
||||
String filename = "file/excel/佣金表" + new Date().getTime() + ".xls";
|
||||
String path = uploadPath + filename;
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
//创建工作表单
|
||||
HSSFSheet sheet = workbook.createSheet();
|
||||
List<UserBalanceLog> list = userBalanceLogService.listRel(param);
|
||||
HSSFRow row = sheet.createRow(0);
|
||||
row.createCell(0).setCellValue("订单号");
|
||||
row.createCell(1).setCellValue("手机号");
|
||||
row.createCell(2).setCellValue("姓名");
|
||||
row.createCell(3).setCellValue("订单金额");
|
||||
row.createCell(4).setCellValue("收/支");
|
||||
row.createCell(5).setCellValue("佣金");
|
||||
row.createCell(6).setCellValue("下单时间");
|
||||
int rowNum = 1;
|
||||
for (UserBalanceLog log : list) {
|
||||
HSSFRow orderRow = sheet.createRow(rowNum);
|
||||
Order order = orderService.getById(log.getOrderId());
|
||||
User user = userService.getById(order.getUserId());
|
||||
orderRow.createCell(0).setCellValue(order.getOrderNo());
|
||||
orderRow.createCell(1).setCellValue(user.getPhone());
|
||||
orderRow.createCell(2).setCellValue(user.getRealName());
|
||||
orderRow.createCell(3).setCellValue(order.getTotalPrice().toString());
|
||||
orderRow.createCell(4).setCellValue(log.getScene().equals(1) ? "退款" : "收入");
|
||||
orderRow.createCell(5).setCellValue((log.getScene().equals(1) ? "-" : "") + log.getMoney().toString());
|
||||
orderRow.createCell(6).setCellValue(DateUtil.formatDateTime(order.getCreateTime()) + " ");
|
||||
rowNum++;
|
||||
}
|
||||
FileOutputStream output = new FileOutputStream(path);
|
||||
workbook.write(output);
|
||||
output.flush();
|
||||
|
||||
FileRecord result = new FileRecord();
|
||||
result.setCreateUserId(getLoginUserId());
|
||||
result.setName(filename);
|
||||
result.setPath(path);
|
||||
result.setUrl(requestURL + "/" + filename);
|
||||
// result.setMerchantCode(getMerchantCode());
|
||||
fileRecordService.save(result);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
//import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
import cn.binarywang.wx.miniapp.util.WxMaConfigHolder;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -26,6 +31,7 @@ import com.gxwebsoft.shop.entity.UserOauth;
|
||||
import com.gxwebsoft.shop.service.UserOauthService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.error.WxRuntimeException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -44,210 +50,230 @@ import static com.gxwebsoft.common.core.constants.RedisConstants.ACCESS_TOKEN_KE
|
||||
@RequestMapping("/api/shop/wx-login")
|
||||
@Api(tags = "微信小程序登录API")
|
||||
public class WxLoginController extends BaseController {
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private ConfigProperties configProperties;
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
@Resource
|
||||
private LoginRecordService loginRecordService;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private WxMaProperties wxMaProperties;
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private ConfigProperties configProperties;
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
@Resource
|
||||
private LoginRecordService loginRecordService;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private WxMaProperties wxMaProperties;
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
// @Autowired
|
||||
// private WxMaService wxMaService;
|
||||
|
||||
|
||||
@ApiOperation("获取微信openId")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PostMapping("/getOpenId")
|
||||
public ApiResult<LoginResult> getOpenId(@RequestBody UserParam userParam, HttpServletRequest request) {
|
||||
// 1.获取openid
|
||||
JSONObject result = getOpenIdByCode(userParam);
|
||||
String openid = result.getString("openid");
|
||||
String unionid = result.getString("unionid");
|
||||
if (openid == null) {
|
||||
return fail("获取openid失败", null);
|
||||
@ApiOperation("获取微信openId")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PostMapping("/getOpenId")
|
||||
public ApiResult<LoginResult> getOpenId(@RequestBody UserParam userParam, HttpServletRequest request) throws WxErrorException {
|
||||
// 1.获取openid
|
||||
JSONObject result = getOpenIdByCode(userParam);
|
||||
String openid = result.getString("openid");
|
||||
String unionid = result.getString("unionid");
|
||||
// WxMaJscode2SessionResult result = getOpenIdByCode(userParam);
|
||||
// String openid = result.getOpenid();
|
||||
// String unionid = result.getUnionid();
|
||||
if (openid == null) {
|
||||
return fail("获取openid失败", null);
|
||||
}
|
||||
// 2.通过openid查询用户是否已存在
|
||||
User user = userOauthService.getByOauthId(openid);
|
||||
// 3.存在则签发token并返回登录成功,不存在则注册新用户
|
||||
if (user == null) {
|
||||
user = addUser(userParam);
|
||||
// 添加第三方用户信息
|
||||
UserOauth uo = new UserOauth();
|
||||
uo.setUserId(user.getUserId());
|
||||
uo.setTenantId(user.getTenantId());
|
||||
uo.setOauthType("MP-WEIXIN");
|
||||
uo.setOauthId(openid);
|
||||
uo.setUnionid(unionid);
|
||||
userOauthService.save(uo);
|
||||
}
|
||||
// 4.签发token
|
||||
loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_LOGIN, null, user.getTenantId(), request);
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
// 2.通过openid查询用户是否已存在
|
||||
User user = userOauthService.getByOauthId(openid);
|
||||
// 3.存在则签发token并返回登录成功,不存在则注册新用户
|
||||
if (user == null) {
|
||||
user = addUser(userParam);
|
||||
// 添加第三方用户信息
|
||||
UserOauth uo = new UserOauth();
|
||||
uo.setUserId(user.getUserId());
|
||||
uo.setTenantId(user.getTenantId());
|
||||
uo.setOauthType("MP-WEIXIN");
|
||||
uo.setOauthId(openid);
|
||||
uo.setUnionid(unionid);
|
||||
userOauthService.save(uo);
|
||||
}
|
||||
// 4.签发token
|
||||
loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_LOGIN, null, user.getTenantId(), request);
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
|
||||
@ApiOperation("微信授权手机号码并登录")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PostMapping("/loginByMpWxPhone")
|
||||
public ApiResult<LoginResult> loginByMpWxPhone(@RequestBody UserParam userParam, HttpServletRequest request) {
|
||||
// 获取手机号码
|
||||
String phone = getPhoneByCode(userParam);
|
||||
// 查询是否存在
|
||||
User user = userService.getByPhone(phone);
|
||||
// 不存在
|
||||
if (user == null) {
|
||||
return fail("该用户不存在", new LoginResult());
|
||||
}
|
||||
// 签发token
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_LOGIN, null, user.getTenantId(), request);
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
@ApiOperation("微信授权手机号码并登录")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PostMapping("/loginByMpWxPhone")
|
||||
public ApiResult<LoginResult> loginByMpWxPhone(@RequestBody UserParam userParam, HttpServletRequest request) throws WxErrorException {
|
||||
// 获取手机号码
|
||||
String phone = getPhoneByCode(userParam);
|
||||
System.out.println("phone:" + phone);
|
||||
|
||||
@ApiOperation("微信授权手机号码并更新")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PostMapping("/updatePhoneByMpWx")
|
||||
public ApiResult<?> updatePhoneByMpWx(@RequestBody UserParam userParam) {
|
||||
// 获取微信授权手机号
|
||||
String phone = getPhoneByCode(userParam);
|
||||
// 查询当前用户
|
||||
User user = userService.getById(userParam.getUserId());
|
||||
if (user != null && phone != null) {
|
||||
user.setPhone(phone);
|
||||
userService.updateUser(user);
|
||||
return success("更新成功",phone);
|
||||
// 查询是否存在
|
||||
User user = userService.getByPhone(phone);
|
||||
System.out.println("用户:" + user);
|
||||
// 不存在
|
||||
if (user == null) {
|
||||
return fail("该用户不存在", new LoginResult());
|
||||
}
|
||||
// 签发token
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_LOGIN, null, user.getTenantId(), request);
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
return fail("更新失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新用户注册
|
||||
*/
|
||||
private User addUser(UserParam userParam) {
|
||||
User addUser = new User();
|
||||
// 注册用户
|
||||
addUser.setStatus(0);
|
||||
addUser.setUsername(createUsername("wx_"));
|
||||
addUser.setNickname("微信用户");
|
||||
addUser.setPassword(userService.encodePassword(CommonUtil.randomUUID16()));
|
||||
addUser.setTenantId(getTenantId());
|
||||
Role role = roleService.getOne(new QueryWrapper<Role>().eq("role_code", "user"), false);
|
||||
addUser.setRoleId(role.getRoleId());
|
||||
if (userService.saveUser(addUser)) {
|
||||
// 添加用户角色
|
||||
final UserRole userRole = new UserRole();
|
||||
userRole.setUserId(addUser.getUserId());
|
||||
userRole.setTenantId(addUser.getTenantId());
|
||||
userRole.setRoleId(addUser.getRoleId());
|
||||
userRoleService.save(userRole);
|
||||
@ApiOperation("微信授权手机号码并更新")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PostMapping("/updatePhoneByMpWx")
|
||||
public ApiResult<?> updatePhoneByMpWx(@RequestBody UserParam userParam) throws WxErrorException {
|
||||
// 获取微信授权手机号
|
||||
String phone = getPhoneByCode(userParam);
|
||||
// 查询当前用户
|
||||
User user = userService.getById(userParam.getUserId());
|
||||
if (user != null && phone != null) {
|
||||
user.setPhone(phone);
|
||||
userService.updateUser(user);
|
||||
return success("更新成功", phone);
|
||||
}
|
||||
return fail("更新失败");
|
||||
}
|
||||
return addUser;
|
||||
}
|
||||
|
||||
// 获取openid
|
||||
private JSONObject getOpenIdByCode(UserParam userParam) {
|
||||
// 获取微信小程序配置信息
|
||||
JSONObject setting = settingService.getBySettingKey("mp-weixin");
|
||||
// 获取openId
|
||||
String apiUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=" + setting.getString("appId") + "&secret=" + setting.getString("appSecret") + "&js_code=" + userParam.getCode() + "&grant_type=authorization_code";
|
||||
// 执行get请求
|
||||
String result = HttpUtil.get(apiUrl);
|
||||
System.out.println("result = " + result);
|
||||
// 解析access_token
|
||||
return JSON.parseObject(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信手机号码
|
||||
*
|
||||
* @param userParam 需要传微信凭证code
|
||||
*/
|
||||
private String getPhoneByCode(UserParam userParam) {
|
||||
// 获取手机号码
|
||||
String apiUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + getAccessToken();
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("code", userParam.getCode());
|
||||
// 执行post请求
|
||||
String post = HttpUtil.post(apiUrl, JSON.toJSONString(paramMap));
|
||||
JSONObject json = JSON.parseObject(post);
|
||||
if (json.get("errcode").equals(0)) {
|
||||
JSONObject phoneInfo = JSON.parseObject(json.getString("phone_info"));
|
||||
// 微信用户的手机号码
|
||||
return phoneInfo.getString("phoneNumber");
|
||||
/**
|
||||
* 新用户注册
|
||||
*/
|
||||
private User addUser(UserParam userParam) {
|
||||
User addUser = new User();
|
||||
// 注册用户
|
||||
addUser.setStatus(0);
|
||||
addUser.setUsername(createUsername("wx_"));
|
||||
addUser.setNickname("微信用户");
|
||||
addUser.setPassword(userService.encodePassword(CommonUtil.randomUUID16()));
|
||||
addUser.setTenantId(getTenantId());
|
||||
Role role = roleService.getOne(new QueryWrapper<Role>().eq("role_code", "user"), false);
|
||||
addUser.setRoleId(role.getRoleId());
|
||||
if (userService.saveUser(addUser)) {
|
||||
// 添加用户角色
|
||||
final UserRole userRole = new UserRole();
|
||||
userRole.setUserId(addUser.getUserId());
|
||||
userRole.setTenantId(addUser.getTenantId());
|
||||
userRole.setRoleId(addUser.getRoleId());
|
||||
userRoleService.save(userRole);
|
||||
}
|
||||
return addUser;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机账号
|
||||
*
|
||||
* @return username
|
||||
*/
|
||||
private String createUsername(String type) {
|
||||
return type.concat(RandomUtil.randomString(12));
|
||||
}
|
||||
// 获取openid
|
||||
private JSONObject getOpenIdByCode(UserParam userParam) {
|
||||
// 获取微信小程序配置信息
|
||||
JSONObject setting = settingService.getBySettingKey("mp-weixin");
|
||||
// 获取openId
|
||||
String apiUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=" + setting.getString("appId") + "&secret=" + setting.getString("appSecret") + "&js_code=" + userParam.getCode() + "&grant_type=authorization_code";
|
||||
// 执行get请求
|
||||
String result = HttpUtil.get(apiUrl);
|
||||
System.out.println("result = " + result);
|
||||
// 解析access_token
|
||||
return JSON.parseObject(result);
|
||||
// return wxMaService.getUserService().getSessionInfo(userParam.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口调用凭据AccessToken
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html
|
||||
*/
|
||||
public String getAccessToken() {
|
||||
// 获取微信小程序配置信息
|
||||
JSONObject setting = settingService.getBySettingKey("mp-weixin");
|
||||
// 从缓存获取access_token
|
||||
String value = redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY.concat(getTenantId().toString()));
|
||||
if (value != null) {
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(value);
|
||||
return response.getString("access_token");
|
||||
/**
|
||||
* 获取微信手机号码
|
||||
*
|
||||
* @param userParam 需要传微信凭证code
|
||||
*/
|
||||
private String getPhoneByCode(UserParam userParam) {
|
||||
// 获取手机号码
|
||||
String apiUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + getAccessToken();
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("code", userParam.getPhoneCode());
|
||||
// 执行post请求
|
||||
String post = HttpUtil.post(apiUrl, JSON.toJSONString(paramMap));
|
||||
JSONObject json = JSON.parseObject(post);
|
||||
System.out.println("json = " + json);
|
||||
if (json.get("errcode").equals(0)) {
|
||||
JSONObject phoneInfo = JSON.parseObject(json.getString("phone_info"));
|
||||
// 微信用户的手机号码
|
||||
return phoneInfo.getString("phoneNumber");
|
||||
}
|
||||
return null;
|
||||
// 解密
|
||||
// WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(userParam.getPhoneCode());
|
||||
// WxMaConfigHolder.remove();//清理ThreadLocal
|
||||
// return phoneNoInfo.getPhoneNumber();
|
||||
}
|
||||
// 微信获取凭证接口
|
||||
String apiUrl = "https://api.weixin.qq.com/cgi-bin/token";
|
||||
// 组装url参数
|
||||
String url = apiUrl.concat("?grant_type=client_credential").concat("&appid=").concat(setting.getString("appId")).concat("&secret=").concat(setting.getString("appSecret"));
|
||||
// 执行get请求
|
||||
String result = HttpUtil.get(url);
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(result);
|
||||
if (response.getString("access_token") != null) {
|
||||
// 存入缓存
|
||||
redisTemplate.opsForValue().set(ACCESS_TOKEN_KEY.concat(getTenantId().toString()), result);
|
||||
return response.getString("access_token");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public WxMaService wxMaService() {
|
||||
List<WxMaProperties.Config> configs = wxMaProperties.getConfigs();
|
||||
if (configs == null) {
|
||||
throw new WxRuntimeException("大哥,拜托先看下项目首页的说明(readme文件),添加下相关配置,注意别配错了!");
|
||||
/**
|
||||
* 生成随机账号
|
||||
*
|
||||
* @return username
|
||||
*/
|
||||
private String createUsername(String type) {
|
||||
return type.concat(RandomUtil.randomString(12));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口调用凭据AccessToken
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html
|
||||
*/
|
||||
public String getAccessToken() {
|
||||
System.out.println(getTenantId());
|
||||
// 获取微信小程序配置信息
|
||||
// JSONObject setting = settingService.getBySettingKey("mp-weixin");
|
||||
String appid = "wx7bdcb7c68d53062b";
|
||||
String secret = "8d747742fa81da3211da1d504e494531";
|
||||
// 从缓存获取access_token
|
||||
String value = redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY.concat(getTenantId().toString()));
|
||||
// if (value != null) {
|
||||
// // 解析access_token
|
||||
// JSONObject response = JSON.parseObject(value);
|
||||
// return response.getString("access_token");
|
||||
// }
|
||||
// 微信获取凭证接口
|
||||
String apiUrl = "https://api.weixin.qq.com/cgi-bin/token";
|
||||
// 组装url参数
|
||||
// String url = apiUrl.concat("?grant_type=client_credential").concat("&appid=").concat(setting.getString("appId")).concat("&secret=").concat(setting.getString("appSecret"));
|
||||
String url = apiUrl.concat("?grant_type=client_credential").concat("&appid=").concat(appid).concat("&secret=").concat(secret);
|
||||
// 执行get请求
|
||||
String result = HttpUtil.get(url);
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(result);
|
||||
return response.getString("access_token");
|
||||
// if (response.getString("access_token") != null) {
|
||||
// 存入缓存
|
||||
// redisTemplate.opsForValue().set(ACCESS_TOKEN_KEY.concat(getTenantId().toString()), result);
|
||||
// return response.getString("access_token");
|
||||
// }
|
||||
// return null;
|
||||
}
|
||||
|
||||
public WxMaService wxMaService() {
|
||||
List<WxMaProperties.Config> configs = wxMaProperties.getConfigs();
|
||||
if (configs == null) {
|
||||
throw new WxRuntimeException("大哥,拜托先看下项目首页的说明(readme文件),添加下相关配置,注意别配错了!");
|
||||
}
|
||||
WxMaService maService = new WxMaServiceImpl();
|
||||
maService.setMultiConfigs(
|
||||
configs.stream()
|
||||
.map(a -> {
|
||||
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
|
||||
config.setAppid(a.getAppid());
|
||||
config.setSecret(a.getSecret());
|
||||
config.setToken(a.getToken());
|
||||
config.setAesKey(a.getAesKey());
|
||||
config.setMsgDataFormat(a.getMsgDataFormat());
|
||||
return config;
|
||||
}).collect(Collectors.toMap(WxMaDefaultConfigImpl::getAppid, a -> a, (o, n) -> o)));
|
||||
return maService;
|
||||
}
|
||||
WxMaService maService = new WxMaServiceImpl();
|
||||
maService.setMultiConfigs(
|
||||
configs.stream()
|
||||
.map(a -> {
|
||||
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
|
||||
config.setAppid(a.getAppid());
|
||||
config.setSecret(a.getSecret());
|
||||
config.setToken(a.getToken());
|
||||
config.setAesKey(a.getAesKey());
|
||||
config.setMsgDataFormat(a.getMsgDataFormat());
|
||||
return config;
|
||||
}).collect(Collectors.toMap(WxMaDefaultConfigImpl::getAppid, a -> a, (o, n) -> o)));
|
||||
return maService;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +1,223 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.common.system.entity.DictData;
|
||||
import com.gxwebsoft.common.system.service.DictDataService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.constants.OrderConstants;
|
||||
import com.gxwebsoft.shop.entity.*;
|
||||
import com.gxwebsoft.shop.service.*;
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
import com.wechat.pay.java.core.RSAConfig;
|
||||
import com.wechat.pay.java.core.notification.NotificationConfig;
|
||||
import com.wechat.pay.java.core.notification.NotificationParser;
|
||||
import com.wechat.pay.java.core.notification.RequestParam;
|
||||
import com.wechat.pay.java.service.partnerpayments.nativepay.model.Amount;
|
||||
import com.wechat.pay.java.service.partnerpayments.nativepay.model.PrepayRequest;
|
||||
import com.wechat.pay.java.service.partnerpayments.nativepay.model.Transaction;
|
||||
import com.wechat.pay.java.service.partnerpayments.model.TransactionAmount;
|
||||
import com.wechat.pay.java.service.partnerpayments.nativepay.NativePayService;
|
||||
import com.wechat.pay.java.service.partnerpayments.nativepay.model.PrepayResponse;
|
||||
import com.wechat.pay.java.service.refund.RefundService;
|
||||
import com.wechat.pay.java.service.refund.model.AmountReq;
|
||||
import com.wechat.pay.java.service.refund.model.CreateRequest;
|
||||
import com.wechat.pay.java.service.refund.model.RefundNotification;
|
||||
import com.wechat.pay.java.service.refund.model.Status;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/wx-pay")
|
||||
@Api(tags = "微信支付API")
|
||||
public class WxPayController extends BaseController
|
||||
{
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Configuration
|
||||
public class WxPayController extends BaseController {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private DictDataService dictDataService;
|
||||
@Resource
|
||||
private OrderRefundService orderRefundService;
|
||||
@Autowired
|
||||
private UserBalanceLogController userBalanceLogController;
|
||||
|
||||
public ApiResult<?> nativePay(@PathVariable String orderId){
|
||||
return success("支付成功");
|
||||
}
|
||||
private final Integer tenantId = 10036;
|
||||
|
||||
@Value("${wxpay.app-id}")
|
||||
public String appId;
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
@Value("${wxpay.mch-id}")
|
||||
public String merchantId;
|
||||
/**
|
||||
* 商户API私钥路径
|
||||
*/
|
||||
@Value("${wxpay.private-key-path}")
|
||||
public String privateKeyPath;
|
||||
/**
|
||||
* 商户证书序列号
|
||||
*/
|
||||
@Value("${wxpay.mch-serial-no}")
|
||||
public String merchantSerialNumber;
|
||||
/**
|
||||
* 商户APIV3密钥
|
||||
*/
|
||||
@Value("${wxpay.api-v3-key}")
|
||||
public String apiV3key;
|
||||
|
||||
@Value("${wxpay.notify-domain}")
|
||||
public String notifyUrl;
|
||||
|
||||
@Value("${wxpay.cert-path}")
|
||||
public String wechatPayCertificatePath;
|
||||
|
||||
private final String spAppId = "wxa67c676fc445590e";
|
||||
private final String spMerchantId = "1615739384";
|
||||
|
||||
public String nativePay(String orderNo, Integer payAmount, String title) {
|
||||
Config config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(spMerchantId)
|
||||
.privateKeyFromPath(privateKeyPath)
|
||||
.merchantSerialNumber(merchantSerialNumber)
|
||||
.apiV3Key(apiV3key)
|
||||
.build();
|
||||
// 构建service
|
||||
NativePayService service = new NativePayService.Builder().config(config).build();
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
Amount amount = new Amount();
|
||||
DictData dictData = dictDataService.getByDictCodeAndName("PAY_TEST_MODE", "模式");
|
||||
if (Integer.valueOf(dictData.getDictDataCode()).equals(0)) {
|
||||
amount.setTotal(1);
|
||||
}else {
|
||||
amount.setTotal(payAmount);
|
||||
}
|
||||
request.setSpAppid(spAppId);
|
||||
request.setSpMchid(spMerchantId);
|
||||
request.setSubAppid(appId);
|
||||
request.setSubMchid(merchantId);
|
||||
request.setAmount(amount);
|
||||
request.setDescription(title);
|
||||
request.setNotifyUrl(notifyUrl);
|
||||
request.setOutTradeNo(orderNo);
|
||||
PrepayResponse response = service.prepay(request);
|
||||
// 调用下单方法,得到应答
|
||||
return response.getCodeUrl();
|
||||
}
|
||||
|
||||
/***
|
||||
* 退款申请
|
||||
* @param orderRefund
|
||||
*/
|
||||
public void refund(OrderRefund orderRefund) {
|
||||
Config config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(spMerchantId)
|
||||
.privateKeyFromPath(privateKeyPath)
|
||||
.merchantSerialNumber(merchantSerialNumber)
|
||||
.apiV3Key(apiV3key)
|
||||
.build();
|
||||
RefundService service = new RefundService.Builder().config(config).build();
|
||||
CreateRequest request = new CreateRequest();
|
||||
// 金额
|
||||
AmountReq amount = new AmountReq();
|
||||
amount.setTotal(orderRefund.getRefundMoney().multiply(BigDecimal.valueOf(100)).longValue());
|
||||
amount.setRefund(orderRefund.getRefundMoney().multiply(BigDecimal.valueOf(100)).longValue());
|
||||
amount.setCurrency("CNY");
|
||||
request.setSubMchid(merchantId);
|
||||
request.setAmount(amount);
|
||||
request.setOutTradeNo(orderRefund.getOrder().getOrderNo());
|
||||
request.setOutRefundNo("R" + orderRefund.getOrder().getOrderNo());
|
||||
String wechatRefundNotifyUrl = "https://vivo-server.gxwebsoft.com/api/shop/wx-pay/refund-notify";
|
||||
request.setNotifyUrl(wechatRefundNotifyUrl);
|
||||
service.create(request);
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/notify")
|
||||
public ApiResult<?> notify(@RequestBody String body, @RequestHeader Map<String, Object> header) throws ParseException {
|
||||
RequestParam requestParam = new RequestParam.Builder()
|
||||
.serialNumber(header.get("wechatpay-serial").toString())
|
||||
.nonce(header.get("wechatpay-nonce").toString())
|
||||
.signature(header.get("wechatpay-signature").toString())
|
||||
.timestamp(header.get("wechatpay-timestamp").toString())
|
||||
.body(body)
|
||||
.build();
|
||||
NotificationConfig config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(spMerchantId)
|
||||
.privateKeyFromPath(privateKeyPath)
|
||||
.merchantSerialNumber(merchantSerialNumber)
|
||||
.apiV3Key(apiV3key)
|
||||
.build();
|
||||
// 初始化 NotificationParser
|
||||
NotificationParser parser = new NotificationParser(config);
|
||||
Transaction transaction = parser.parse(requestParam, Transaction.class);
|
||||
TransactionAmount transactionAmount = transaction.getAmount();
|
||||
// 支付金额
|
||||
Integer payAmount = transactionAmount.getPayerTotal();
|
||||
float calAmount = (float) payAmount / 100f;
|
||||
BigDecimal userPaid = BigDecimal.valueOf(calAmount);
|
||||
// 订单号
|
||||
String orderNo = transaction.getOutTradeNo();
|
||||
// 微信支付订单号
|
||||
String transactionId = transaction.getTransactionId();
|
||||
// 支付状态
|
||||
Transaction.TradeStateEnum tradeStateEnum = transaction.getTradeState();
|
||||
System.out.println("支付结果:" + transaction);
|
||||
if (tradeStateEnum == Transaction.TradeStateEnum.SUCCESS) {
|
||||
Order order = orderService.getByOutTradeNo(orderNo);
|
||||
order.setOrderStatus(OrderConstants.ORDER_STATUS_PAID);
|
||||
order.setPayMethod(OrderConstants.ORDER_PAY_METHOD_WECHAT.toString());
|
||||
order.setTradeId(transactionId);
|
||||
order.setReceiptAmount(userPaid);
|
||||
order.setPayTime(DateUtil.date());
|
||||
orderService.updateById(order);
|
||||
|
||||
orderService.updateIncome(order);
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
@PostMapping("/refund-notify")
|
||||
public ApiResult<?> refundNotify(@RequestBody String body, @RequestHeader Map<String, Object> header) throws ParseException {
|
||||
RequestParam requestParam = new RequestParam.Builder()
|
||||
.serialNumber(header.get("wechatpay-serial").toString())
|
||||
.nonce(header.get("wechatpay-nonce").toString())
|
||||
.signature(header.get("wechatpay-signature").toString())
|
||||
.timestamp(header.get("wechatpay-timestamp").toString())
|
||||
.body(body)
|
||||
.build();
|
||||
NotificationConfig config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(spMerchantId)
|
||||
.privateKeyFromPath(privateKeyPath)
|
||||
.merchantSerialNumber(merchantSerialNumber)
|
||||
.apiV3Key(apiV3key)
|
||||
.build();
|
||||
// 初始化 NotificationParser
|
||||
NotificationParser parser = new NotificationParser(config);
|
||||
RefundNotification notification = parser.parse(requestParam, RefundNotification.class);
|
||||
String orderNo = notification.getOutTradeNo();
|
||||
if (notification.getRefundStatus().equals(Status.SUCCESS)) {
|
||||
Order order = orderService.getByOutTradeNo(orderNo);
|
||||
OrderRefund orderRefund = orderRefundService.getByOrderId(order.getOrderId());
|
||||
if (orderRefund.getRefundStatus().equals(0)) {
|
||||
orderRefund.setRefundStatus(1);
|
||||
orderRefundService.updateById(orderRefund);
|
||||
}
|
||||
}
|
||||
return success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品记录表
|
||||
@@ -148,6 +149,9 @@ public class Goods implements Serializable {
|
||||
@ApiModelProperty(value = "分销佣金(三级)")
|
||||
private BigDecimal thirdMoney;
|
||||
|
||||
@ApiModelProperty(value = "成本")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@@ -192,4 +196,10 @@ public class Goods implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private Integer noDeliveryTimes;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<GoodsPhoneModel> goodsPhoneModelList;
|
||||
|
||||
@TableField(exist = false)
|
||||
private GoodsPrice goodsPrice;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.gxwebsoft.shop.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商品匹配机型
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:30:55
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "GoodsPhoneModel对象", description = "商品匹配机型")
|
||||
@TableName("shop_goods_phone_model")
|
||||
public class GoodsPhoneModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer goodsId;
|
||||
|
||||
private Integer modelId;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0上架, 1下架")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String phoneModelName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String phoneModelCode;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.gxwebsoft.shop.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商品价格()
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:35:40
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "GoodsPrice对象", description = "商品价格()")
|
||||
@TableName("shop_goods_price")
|
||||
public class GoodsPrice implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer goodsId;
|
||||
|
||||
@ApiModelProperty(value = "售价")
|
||||
private BigDecimal amount;
|
||||
|
||||
@ApiModelProperty(value = "零售商店长返利比例")
|
||||
@TableField(value = "level_3_commission_rate")
|
||||
private BigDecimal level3commissionRate;
|
||||
|
||||
@ApiModelProperty(value = "零售商店长返利模式(0金额1比例)")
|
||||
@TableField(value = "level_3_commission_mode")
|
||||
private Integer level3commissionMode;
|
||||
|
||||
@ApiModelProperty(value = "导购返利比例")
|
||||
@TableField(value = "level_4_commission_rate")
|
||||
private BigDecimal level4commissionRate;
|
||||
|
||||
@ApiModelProperty(value = "导购返利模式(0金额1比例)")
|
||||
@TableField(value = "level_4_commission_mode")
|
||||
private Integer level4commissionMode;
|
||||
|
||||
@ApiModelProperty(value = "售后返利比例")
|
||||
@TableField(value = "level_5_commission_rate")
|
||||
private BigDecimal level5commissionRate;
|
||||
|
||||
@ApiModelProperty(value = "散户返利比例")
|
||||
@TableField(value = "level_6_commission_rate")
|
||||
private BigDecimal level6commissionRate;
|
||||
|
||||
@ApiModelProperty(value = "散户返利模式(0金额1比例)")
|
||||
@TableField(value = "level_6_commission_mode")
|
||||
private Integer level6commissionMode;
|
||||
|
||||
@ApiModelProperty(value = "编外合伙人返利比例")
|
||||
@TableField(value = "level_7_commission_rate")
|
||||
private BigDecimal level7commissionRate;
|
||||
|
||||
@ApiModelProperty(value = "编外合伙人返利模式(0金额1比例)")
|
||||
@TableField(value = "level_7_commission_mode")
|
||||
private Integer level7commissionMode;
|
||||
|
||||
@ApiModelProperty(value = "售后店长返利比例")
|
||||
@TableField(value = "level_8_commission_rate")
|
||||
private BigDecimal level8commissionRate;
|
||||
|
||||
@ApiModelProperty(value = "售后店长全店返利比例")
|
||||
private BigDecimal fixStoreLeaderCommissionRate;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0上架, 1下架")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
private Integer province;
|
||||
|
||||
private Integer city;
|
||||
|
||||
@ApiModelProperty(value = "区代ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.gxwebsoft.shop.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.gxwebsoft.apps.entity.Equipment;
|
||||
import com.gxwebsoft.apps.entity.EquipmentOrderGoods;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.vivo.entity.VivoFixStore;
|
||||
import com.gxwebsoft.vivo.entity.VivoStore;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -34,7 +35,7 @@ public class Order implements Serializable {
|
||||
private String subject;
|
||||
|
||||
@ApiModelProperty(value = "订单号")
|
||||
private Long orderNo;
|
||||
private String orderNo;
|
||||
|
||||
@ApiModelProperty(value = "商品总金额(不含优惠折扣)")
|
||||
private BigDecimal totalPrice;
|
||||
@@ -177,12 +178,25 @@ public class Order implements Serializable {
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "所属城市")
|
||||
private Integer cityId;
|
||||
|
||||
@ApiModelProperty(value = "所属门店ID")
|
||||
private Integer shopId;
|
||||
private Integer storeId;
|
||||
|
||||
@ApiModelProperty(value = "所属门店ID")
|
||||
private Integer fixStoreId;
|
||||
|
||||
@ApiModelProperty(value = "所属零售商ID")
|
||||
private Integer orgId;
|
||||
|
||||
@ApiModelProperty(value = "商品ID")
|
||||
private Integer goodsId;
|
||||
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
@TableField(exist = false)
|
||||
private String goodsName;
|
||||
|
||||
@ApiModelProperty(value = "设备ID")
|
||||
private Integer equipmentId;
|
||||
|
||||
@@ -199,6 +213,59 @@ public class Order implements Serializable {
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "照片")
|
||||
private String photo;
|
||||
|
||||
@ApiModelProperty(value = "视频")
|
||||
private String video;
|
||||
|
||||
@ApiModelProperty(value = "支付凭证")
|
||||
private String payVoucher;
|
||||
|
||||
@ApiModelProperty(value = "分佣")
|
||||
private BigDecimal commission;
|
||||
|
||||
@ApiModelProperty(value = "区代毛利")
|
||||
private BigDecimal agentCommission;
|
||||
|
||||
@ApiModelProperty(value = "店长门店返利")
|
||||
private BigDecimal fixStoreLeaderCommission;
|
||||
|
||||
@ApiModelProperty(value = "退款码")
|
||||
private String refundCode;
|
||||
|
||||
@ApiModelProperty(value = "型号")
|
||||
private String modelName;
|
||||
|
||||
@ApiModelProperty(value = "RAM+ROM")
|
||||
private String productMemory;
|
||||
|
||||
private String imei;
|
||||
|
||||
private String skuCode;
|
||||
|
||||
private String skuName;
|
||||
|
||||
private String skuColor;
|
||||
|
||||
@ApiModelProperty("门店")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty("二级区域名称")
|
||||
private String secondAreaName;
|
||||
|
||||
@ApiModelProperty("零售商名称")
|
||||
private String retailerName;
|
||||
|
||||
@ApiModelProperty("好/坏")
|
||||
private String goodOrBad;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@@ -215,6 +282,9 @@ public class Order implements Serializable {
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty(value = "出险时间")
|
||||
private Date useTime;
|
||||
|
||||
@ApiModelProperty("账号")
|
||||
@TableField(exist = false)
|
||||
private String username;
|
||||
@@ -227,10 +297,6 @@ public class Order implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "联系电话")
|
||||
@TableField(exist = false)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "头像")
|
||||
@TableField(exist = false)
|
||||
private String avatar;
|
||||
@@ -247,15 +313,39 @@ public class Order implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private List<OrderGoods> goodsList;
|
||||
|
||||
@ApiModelProperty("管理电池商品")
|
||||
@ApiModelProperty("商品列表")
|
||||
@TableField(exist = false)
|
||||
private EquipmentOrderGoods equipmentGoods;
|
||||
|
||||
@ApiModelProperty("设备")
|
||||
@TableField(exist = false)
|
||||
private Equipment equipment;
|
||||
private OrderGoods orderGoods;
|
||||
|
||||
@ApiModelProperty("推荐人ID")
|
||||
@TableField(exist = false)
|
||||
private Integer dealerId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Goods goods;
|
||||
|
||||
@ApiModelProperty("上报人姓名")
|
||||
private String sellerName;
|
||||
|
||||
@ApiModelProperty("上报人工号")
|
||||
private String sellerCode;
|
||||
|
||||
@ApiModelProperty("后台状态:已激活/未激活")
|
||||
private String activeState;
|
||||
|
||||
@ApiModelProperty("后台激活日期")
|
||||
private String activeDate;
|
||||
|
||||
@TableField(exist = false)
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@TableField(exist = false)
|
||||
private VivoStore store;
|
||||
|
||||
@TableField(exist = false)
|
||||
private VivoFixStore fixStore;
|
||||
|
||||
@TableField(exist = false)
|
||||
private User user;
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,9 @@ public class OrderRefund implements Serializable {
|
||||
@ApiModelProperty(value = "商家审核状态(0待审核 10已同意 20已拒绝)")
|
||||
private Integer auditStatus;
|
||||
|
||||
@ApiModelProperty(value = "0未到账1已到账")
|
||||
private Integer refundStatus;
|
||||
|
||||
@ApiModelProperty(value = "商家拒绝原因(说明)")
|
||||
private String refuseDesc;
|
||||
|
||||
@@ -113,5 +116,6 @@ public class OrderRefund implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String merchantName;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private Order order;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -33,7 +34,14 @@ public class UserBalanceLog implements Serializable {
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "余额变动场景(10用户充值 20用户消费 30管理员操作 40订单退款)")
|
||||
@ApiModelProperty(value = "订单ID")
|
||||
private Integer orderId;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "订单")
|
||||
private Order order;
|
||||
|
||||
@ApiModelProperty(value = "余额变动场景余额变动场景(0分佣 1订单退款)")
|
||||
private Integer scene;
|
||||
|
||||
@ApiModelProperty(value = "变动金额")
|
||||
@@ -78,4 +86,10 @@ public class UserBalanceLog implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String avatar;
|
||||
|
||||
@TableField(exist = false)
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@TableField(exist = false)
|
||||
private User user;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.shop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.shop.entity.GoodsPhoneModel;
|
||||
import com.gxwebsoft.shop.param.GoodsPhoneModelParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品匹配机型Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:30:55
|
||||
*/
|
||||
public interface GoodsPhoneModelMapper extends BaseMapper<GoodsPhoneModel> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<GoodsPhoneModel>
|
||||
*/
|
||||
List<GoodsPhoneModel> selectPageRel(@Param("page") IPage<GoodsPhoneModel> page,
|
||||
@Param("param") GoodsPhoneModelParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<GoodsPhoneModel> selectListRel(@Param("param") GoodsPhoneModelParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.shop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.shop.entity.GoodsPrice;
|
||||
import com.gxwebsoft.shop.param.GoodsPriceParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品价格()Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:35:40
|
||||
*/
|
||||
public interface GoodsPriceMapper extends BaseMapper<GoodsPrice> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<GoodsPrice>
|
||||
*/
|
||||
List<GoodsPrice> selectPageRel(@Param("page") IPage<GoodsPrice> page,
|
||||
@Param("param") GoodsPriceParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<GoodsPrice> selectListRel(@Param("param") GoodsPriceParam param);
|
||||
|
||||
}
|
||||
@@ -5,10 +5,8 @@
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*,
|
||||
b.merchant_name,b.merchant_code,
|
||||
c.title as categoryName,c.parent_id,c.category_id
|
||||
FROM shop_goods a
|
||||
LEFT JOIN shop_merchant b ON a.merchant_code = b.merchant_code
|
||||
LEFT JOIN shop_category c ON a.category_id = c.category_id
|
||||
<where>
|
||||
<if test="param.goodsId != null">
|
||||
@@ -143,9 +141,7 @@
|
||||
<if test="param.merchantCode != null">
|
||||
AND a.merchant_code = #{param.merchantCode}
|
||||
</if>
|
||||
<if test="param.merchantName != null">
|
||||
AND b.merchant_name = #{param.merchantName}
|
||||
</if>
|
||||
|
||||
<if test="param.period != null">
|
||||
AND a.period = #{param.period}
|
||||
</if>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.shop.mapper.GoodsPhoneModelMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*, b.name as phone_model_name, b.code as phone_model_code
|
||||
FROM shop_goods_phone_model a
|
||||
LEFT JOIN vivo_phone_model b ON a.model_id = b.id
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.goodsId != null">
|
||||
AND a.goods_id = #{param.goodsId}
|
||||
</if>
|
||||
<if test="param.modelId != null">
|
||||
AND a.model_id = #{param.modelId}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.GoodsPhoneModel">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.GoodsPhoneModel">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.shop.mapper.GoodsPriceMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_goods_price a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.goodsId != null">
|
||||
AND a.goods_id = #{param.goodsId}
|
||||
</if>
|
||||
<if test="param.amount != null">
|
||||
AND a.amount = #{param.amount}
|
||||
</if>
|
||||
<if test="param.commissionRate != null">
|
||||
AND a.commission_rate = #{param.commissionRate}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.province != null">
|
||||
AND a.province LIKE CONCAT('%', #{param.province}, '%')
|
||||
</if>
|
||||
<if test="param.city != null">
|
||||
AND a.city LIKE CONCAT('%', #{param.city}, '%')
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.GoodsPrice">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.GoodsPrice">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -5,16 +5,13 @@
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*,
|
||||
b.nickname,b.alias,b.username,b.user_id,b.avatar,b.phone,b.email,
|
||||
c.equipment_name,c.equipment_code,c.equipment_category,c.equipment_avatar,c.battery_model,c.equipment_id,
|
||||
d.merchant_name,d.merchant_code,
|
||||
e.organization_id,e.organization_name
|
||||
b.nickname,b.alias,b.username,b.user_id,b.avatar,b.phone,b.real_name,
|
||||
c.goods_name
|
||||
FROM shop_order a
|
||||
LEFT JOIN sys_user b ON a.user_id = b.user_id
|
||||
LEFT JOIN apps_equipment c ON a.equipment_id = c.equipment_id
|
||||
LEFT JOIN shop_merchant d ON a.merchant_code = d.merchant_code
|
||||
LEFT JOIN sys_organization e ON b.organization_id = e.organization_id
|
||||
LEFT JOIN shop_goods c ON c.goods_id = a.goods_id
|
||||
<where>
|
||||
AND a.order_status != 0
|
||||
<if test="param.orderId != null">
|
||||
AND a.order_id = #{param.orderId}
|
||||
</if>
|
||||
@@ -111,6 +108,9 @@
|
||||
<if test="param.transactionId != null">
|
||||
AND a.transaction_id LIKE CONCAT('%', #{param.transactionId}, '%')
|
||||
</if>
|
||||
<if test="param.imei != null">
|
||||
AND a.imei LIKE CONCAT('%', #{param.imei}, '%')
|
||||
</if>
|
||||
<if test="param.isComment != null">
|
||||
AND a.is_comment = #{param.isComment}
|
||||
</if>
|
||||
@@ -144,8 +144,20 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.shopId != null">
|
||||
AND a.shop_id = #{param.shopId}
|
||||
<if test="param.storeId != null">
|
||||
AND a.store_id = #{param.storeId}
|
||||
</if>
|
||||
<if test="param.fixStoreId != null">
|
||||
AND a.fix_store_id = #{param.fixStoreId}
|
||||
</if>
|
||||
<if test="param.fixOnly != null">
|
||||
AND a.fix_store_id != 0
|
||||
</if>
|
||||
<if test="param.orgId != null">
|
||||
AND a.org_id = #{param.orgId}
|
||||
</if>
|
||||
<if test="param.cityId != null">
|
||||
AND a.city_id = #{param.cityId}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
@@ -174,16 +186,23 @@
|
||||
<if test="param.merchantCode != null">
|
||||
AND a.merchant_code = #{param.merchantCode}
|
||||
</if>
|
||||
<if test="param.userLevel != null">
|
||||
AND b.user_level = #{param.userLevel}
|
||||
</if>
|
||||
<if test="param.userLevelList != null">
|
||||
AND b.user_level IN
|
||||
<foreach collection="param.userLevelList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (
|
||||
a.order_no = #{param.keywords}
|
||||
OR a.order_id = #{param.keywords}
|
||||
OR a.user_id = #{param.keywords}
|
||||
OR a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR b.nickname LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR b.phone = #{param.keywords}
|
||||
OR c.equipment_code = #{param.keywords}
|
||||
OR d.merchant_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
a.order_no LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.phone LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.sku_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.imei LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR b.phone LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR b.real_name LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.shop.param;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商品匹配机型查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:30:55
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "GoodsPhoneModelParam对象", description = "商品匹配机型查询参数")
|
||||
public class GoodsPhoneModelParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer goodsId;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer modelId;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0上架, 1下架")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.gxwebsoft.shop.param;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 商品价格()查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:35:40
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "GoodsPriceParam对象", description = "商品价格()查询参数")
|
||||
public class GoodsPriceParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer goodsId;
|
||||
|
||||
@ApiModelProperty(value = "售价")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal amount;
|
||||
|
||||
@ApiModelProperty(value = "返利比例")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal commissionRate;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0上架, 1下架")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
private String province;
|
||||
|
||||
private String city;
|
||||
|
||||
@ApiModelProperty(value = "区代ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -69,6 +70,8 @@ public class OrderParam extends BaseParam {
|
||||
@ApiModelProperty(value = "买家留言")
|
||||
private String buyerRemark;
|
||||
|
||||
private String imei;
|
||||
|
||||
@ApiModelProperty(value = "支付方式(废弃)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer payType;
|
||||
@@ -186,7 +189,19 @@ public class OrderParam extends BaseParam {
|
||||
|
||||
@ApiModelProperty(value = "所属门店ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer shopId;
|
||||
private Integer storeId;
|
||||
|
||||
@ApiModelProperty(value = "所属门店ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer fixStoreId;
|
||||
|
||||
@ApiModelProperty(value = "所属零售商ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer orgId;
|
||||
|
||||
@ApiModelProperty(value = "所属门店ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer cityId;
|
||||
|
||||
@ApiModelProperty(value = "商品ID")
|
||||
private Integer goodsId;
|
||||
@@ -237,4 +252,16 @@ public class OrderParam extends BaseParam {
|
||||
@TableField(exist = false)
|
||||
private Set<Integer> userIds;
|
||||
|
||||
@ApiModelProperty(value = "仅显示售后店订单")
|
||||
@TableField(exist = false)
|
||||
private Integer fixOnly;
|
||||
|
||||
@ApiModelProperty(value = "用户等级集合")
|
||||
@TableField(exist = false)
|
||||
private List<Integer> userLevelList;
|
||||
|
||||
@ApiModelProperty(value = "用户等级")
|
||||
@TableField(exist = false)
|
||||
private Integer userLevel;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.gxwebsoft.shop.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.GoodsPhoneModel;
|
||||
import com.gxwebsoft.shop.param.GoodsPhoneModelParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品匹配机型Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:30:55
|
||||
*/
|
||||
public interface GoodsPhoneModelService extends IService<GoodsPhoneModel> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<GoodsPhoneModel>
|
||||
*/
|
||||
PageResult<GoodsPhoneModel> pageRel(GoodsPhoneModelParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<GoodsPhoneModel>
|
||||
*/
|
||||
List<GoodsPhoneModel> listRel(GoodsPhoneModelParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return GoodsPhoneModel
|
||||
*/
|
||||
GoodsPhoneModel getByIdRel(Integer id);
|
||||
|
||||
List<GoodsPhoneModel> getByModelId(Integer modelId);
|
||||
|
||||
void delByGoodsId(Integer goodsId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.gxwebsoft.shop.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.GoodsPrice;
|
||||
import com.gxwebsoft.shop.param.GoodsPriceParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品价格()Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:35:40
|
||||
*/
|
||||
public interface GoodsPriceService extends IService<GoodsPrice> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<GoodsPrice>
|
||||
*/
|
||||
PageResult<GoodsPrice> pageRel(GoodsPriceParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<GoodsPrice>
|
||||
*/
|
||||
List<GoodsPrice> listRel(GoodsPriceParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return GoodsPrice
|
||||
*/
|
||||
GoodsPrice getByIdRel(Integer id);
|
||||
|
||||
GoodsPrice getByGoodsIdNCity(Integer id, Integer cityId);
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.gxwebsoft.shop.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.entity.Goods;
|
||||
import com.gxwebsoft.shop.param.GoodsParam;
|
||||
|
||||
@@ -39,4 +40,9 @@ public interface GoodsService extends IService<Goods> {
|
||||
*/
|
||||
Goods getByIdRel(Integer goodsId);
|
||||
|
||||
List<Goods> getByPhoneModelCode(String modelCode);
|
||||
|
||||
List<Goods> getByPhoneModel(String phoneModel);
|
||||
|
||||
void setData(List<Goods> goodsList, User loginUser );
|
||||
}
|
||||
|
||||
@@ -39,4 +39,6 @@ public interface OrderRefundService extends IService<OrderRefund> {
|
||||
*/
|
||||
OrderRefund getByIdRel(Integer orderRefundId);
|
||||
|
||||
OrderRefund getByOrderId(Integer orderId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.gxwebsoft.shop.service;
|
||||
|
||||
import com.alipay.api.response.AlipayTradeQueryResponse;
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -26,6 +27,8 @@ public interface OrderService extends IService<Order> {
|
||||
*/
|
||||
PageResult<Order> pageRel(OrderParam param);
|
||||
|
||||
Page<Order> getByPage(OrderParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
@@ -44,9 +47,6 @@ public interface OrderService extends IService<Order> {
|
||||
|
||||
Order getByOutTradeNo(String outTradeNo);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
void paySuccess(AlipayTradeQueryResponse params);
|
||||
|
||||
boolean allinPay(Map<String, String> params);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
@@ -57,6 +57,11 @@ public interface OrderService extends IService<Order> {
|
||||
|
||||
PageResult<Order> selectPageSettled(OrderParam param);
|
||||
|
||||
void updateByIdSettled(Order order);
|
||||
Integer countNum(OrderParam param);
|
||||
|
||||
BigDecimal sumData(OrderParam param, String field);
|
||||
|
||||
BigDecimal sumIncome(OrderParam param);
|
||||
|
||||
void updateIncome(Order order);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gxwebsoft.shop.service;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.UserBalanceLog;
|
||||
import com.gxwebsoft.shop.param.UserBalanceLogParam;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -39,4 +40,6 @@ public interface UserBalanceLogService extends IService<UserBalanceLog> {
|
||||
*/
|
||||
UserBalanceLog getByIdRel(Integer logId);
|
||||
|
||||
BigDecimal sumData(UserBalanceLogParam param);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.shop.mapper.GoodsPhoneModelMapper;
|
||||
import com.gxwebsoft.shop.service.GoodsPhoneModelService;
|
||||
import com.gxwebsoft.shop.entity.GoodsPhoneModel;
|
||||
import com.gxwebsoft.shop.param.GoodsPhoneModelParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品匹配机型Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:30:55
|
||||
*/
|
||||
@Service
|
||||
public class GoodsPhoneModelServiceImpl extends ServiceImpl<GoodsPhoneModelMapper, GoodsPhoneModel> implements GoodsPhoneModelService {
|
||||
|
||||
@Override
|
||||
public PageResult<GoodsPhoneModel> pageRel(GoodsPhoneModelParam param) {
|
||||
PageParam<GoodsPhoneModel, GoodsPhoneModelParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<GoodsPhoneModel> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GoodsPhoneModel> listRel(GoodsPhoneModelParam param) {
|
||||
List<GoodsPhoneModel> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<GoodsPhoneModel, GoodsPhoneModelParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GoodsPhoneModel getByIdRel(Integer id) {
|
||||
GoodsPhoneModelParam param = new GoodsPhoneModelParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GoodsPhoneModel> getByModelId(Integer modelId) {
|
||||
return list(
|
||||
new LambdaQueryWrapper<GoodsPhoneModel>()
|
||||
.eq(GoodsPhoneModel::getModelId, modelId)
|
||||
.eq(GoodsPhoneModel::getDeleted, 0)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delByGoodsId(Integer goodsId) {
|
||||
remove(
|
||||
new LambdaQueryWrapper<GoodsPhoneModel>()
|
||||
.eq(GoodsPhoneModel::getGoodsId, goodsId)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.shop.entity.GoodsService;
|
||||
import com.gxwebsoft.shop.mapper.GoodsPriceMapper;
|
||||
import com.gxwebsoft.shop.service.GoodsPriceService;
|
||||
import com.gxwebsoft.shop.entity.GoodsPrice;
|
||||
import com.gxwebsoft.shop.param.GoodsPriceParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品价格()Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-12 01:35:40
|
||||
*/
|
||||
@Service
|
||||
public class GoodsPriceServiceImpl extends ServiceImpl<GoodsPriceMapper, GoodsPrice> implements GoodsPriceService {
|
||||
|
||||
@Override
|
||||
public PageResult<GoodsPrice> pageRel(GoodsPriceParam param) {
|
||||
PageParam<GoodsPrice, GoodsPriceParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<GoodsPrice> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GoodsPrice> listRel(GoodsPriceParam param) {
|
||||
List<GoodsPrice> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<GoodsPrice, GoodsPriceParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GoodsPrice getByIdRel(Integer id) {
|
||||
GoodsPriceParam param = new GoodsPriceParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GoodsPrice getByGoodsIdNCity(Integer id, Integer cityId) {
|
||||
return getOne(
|
||||
new LambdaQueryWrapper<GoodsPrice>()
|
||||
.eq(GoodsPrice::getGoodsId, id)
|
||||
.eq(GoodsPrice::getCity, cityId)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,26 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.entity.Goods;
|
||||
import com.gxwebsoft.shop.entity.GoodsPhoneModel;
|
||||
import com.gxwebsoft.shop.entity.GoodsPrice;
|
||||
import com.gxwebsoft.shop.mapper.GoodsMapper;
|
||||
import com.gxwebsoft.shop.param.GoodsParam;
|
||||
import com.gxwebsoft.shop.param.GoodsPhoneModelParam;
|
||||
import com.gxwebsoft.shop.service.GoodsPhoneModelService;
|
||||
import com.gxwebsoft.shop.service.GoodsPriceService;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
import com.gxwebsoft.vivo.entity.VivoPhoneModel;
|
||||
import com.gxwebsoft.vivo.service.VivoPhoneModelService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 商品记录表Service实现
|
||||
@@ -20,6 +31,13 @@ import java.util.List;
|
||||
@Service
|
||||
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
|
||||
|
||||
@Resource
|
||||
private VivoPhoneModelService vivoPhoneModelService;
|
||||
@Resource
|
||||
private GoodsPhoneModelService goodsPhoneModelService;
|
||||
@Resource
|
||||
private GoodsPriceService goodsPriceService;
|
||||
|
||||
@Override
|
||||
public PageResult<Goods> pageRel(GoodsParam param) {
|
||||
PageParam<Goods, GoodsParam> page = new PageParam<>(param);
|
||||
@@ -44,4 +62,45 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Goods> getByPhoneModelCode(String modelCode) {
|
||||
VivoPhoneModel vivoPhoneModel = vivoPhoneModelService.getModelByCode(modelCode);
|
||||
if (vivoPhoneModel != null) {
|
||||
List<GoodsPhoneModel> goodsPhoneModel = goodsPhoneModelService.getByModelId(vivoPhoneModel.getId());
|
||||
if (!goodsPhoneModel.isEmpty()) {
|
||||
return list(
|
||||
new LambdaQueryWrapper<Goods>()
|
||||
.in(Goods::getGoodsId, goodsPhoneModel.stream().map(GoodsPhoneModel::getGoodsId).collect(Collectors.toList()))
|
||||
);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Goods> getByPhoneModel(String phoneModel) {
|
||||
VivoPhoneModel vivoPhoneModel = vivoPhoneModelService.getModelByName(phoneModel);
|
||||
if (vivoPhoneModel != null) {
|
||||
List<GoodsPhoneModel> goodsPhoneModel = goodsPhoneModelService.getByModelId(vivoPhoneModel.getId());
|
||||
if (!goodsPhoneModel.isEmpty()) {
|
||||
return list(
|
||||
new LambdaQueryWrapper<Goods>()
|
||||
.in(Goods::getGoodsId, goodsPhoneModel.stream().map(GoodsPhoneModel::getGoodsId).collect(Collectors.toList()))
|
||||
);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(List<Goods> goodsList, User loginUser ) {
|
||||
goodsList.forEach(goods -> {
|
||||
goods.setGoodsPhoneModelList(goodsPhoneModelService.listRel(
|
||||
new GoodsPhoneModelParam() {{
|
||||
setGoodsId(goods.getGoodsId());
|
||||
}}));
|
||||
GoodsPrice goodsPrice = goodsPriceService.getByGoodsIdNCity(goods.getGoodsId(), loginUser.getCityId());
|
||||
goods.setGoodsPrice(goodsPrice);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.shop.mapper.OrderRefundMapper;
|
||||
import com.gxwebsoft.shop.service.OrderRefundService;
|
||||
@@ -44,4 +45,12 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderRefund getByOrderId(Integer orderId) {
|
||||
return getOne(
|
||||
new LambdaQueryWrapper<OrderRefund>()
|
||||
.eq(OrderRefund::getOrderId, orderId)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,34 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alipay.api.response.AlipayTradeQueryResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.apps.service.EquipmentGoodsService;
|
||||
import com.gxwebsoft.apps.service.EquipmentService;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.OrderGoods;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.entity.*;
|
||||
import com.gxwebsoft.shop.mapper.OrderMapper;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import com.gxwebsoft.shop.service.GoodsPriceService;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
import com.gxwebsoft.shop.service.OrderGoodsService;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.service.UserBalanceLogService;
|
||||
import com.gxwebsoft.vivo.entity.VivoFixStore;
|
||||
import com.gxwebsoft.vivo.service.VivoFixStoreService;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -39,98 +46,128 @@ import static com.gxwebsoft.common.core.constants.OrderConstants.*;
|
||||
*/
|
||||
@Service
|
||||
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
|
||||
@Resource
|
||||
private EquipmentService equipmentService;
|
||||
@Resource
|
||||
private EquipmentGoodsService equipmentGoodsService;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
|
||||
@Override
|
||||
public PageResult<Order> pageRel(OrderParam param) {
|
||||
PageParam<Order, OrderParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("delivery_time desc,create_time desc");
|
||||
List<Order> list = baseMapper.selectPageRel(page, param);
|
||||
// 是否查询订单商品
|
||||
if(param.getShowGoodsList() != null){
|
||||
list.forEach(d -> {
|
||||
final List<OrderGoods> goodsList = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderId, d.getOrderId()).gt(OrderGoods::getTotalNum, 0));
|
||||
goodsList.forEach(g -> {
|
||||
// 比较时间前后判断是否允许取消报餐
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date newDate = DateUtil.offset(d.getDeliveryTime(), DateField.HOUR, 21);
|
||||
try {
|
||||
Date date1 = df.parse(newDate.toString());
|
||||
Date date2 = df.parse(DateUtil.now());
|
||||
g.setIsCancel(date1.after(date2));
|
||||
final boolean before = date1.after(date2);
|
||||
System.out.println("before = " + before);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
d.setGoodsList(goodsList);
|
||||
});
|
||||
}
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
@Resource
|
||||
private VivoFixStoreService fixStoreService;
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
@Override
|
||||
public List<Order> listRel(OrderParam param) {
|
||||
List<Order> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Order, OrderParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getByIdRel(Integer orderId) {
|
||||
OrderParam param = new OrderParam();
|
||||
param.setOrderId(orderId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getByOutTradeNo(String outTradeNo) {
|
||||
OrderParam param = new OrderParam();
|
||||
param.setOrderNo(outTradeNo);
|
||||
return param.getOne(baseMapper.getOne(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付成功后处理的业务(通联支付)
|
||||
*/
|
||||
@Override
|
||||
public boolean allinPay(Map<String, String> params) {
|
||||
cacheClient.set(":payInfo", params.toString());
|
||||
final String outTradeNo = params.get("merchantOrderNo");
|
||||
final String trxamt = params.get("trxamt");
|
||||
final String merchantNo = params.get("merchantNo");
|
||||
final String chnltrxid = params.get("chnltrxid");
|
||||
final String payTime = params.get("payTime");
|
||||
final String fee = params.get("fee");
|
||||
final String trxStatus = params.get("trxstatus");
|
||||
|
||||
// 1.是否为商城订单
|
||||
Order order = orderService.getByOutTradeNo(outTradeNo);
|
||||
if (order == null) {
|
||||
return false;
|
||||
@Override
|
||||
public PageResult<Order> pageRel(OrderParam param) {
|
||||
PageParam<Order, OrderParam> page = new PageParam<>(param);
|
||||
// param.setOrder("desc");
|
||||
// param.setSort("create_time");
|
||||
page.setDefaultOrder("create_time desc, order_id desc");
|
||||
List<Order> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
// 2.订单金额是否一致
|
||||
final BigDecimal payPrice = new BigDecimal(trxamt).divide(new BigDecimal(100));
|
||||
@Override
|
||||
public Page<Order> getByPage(OrderParam param) {
|
||||
Page<Order> pageParam = new Page<>(param.getPage(), param.getLimit());
|
||||
MPJQueryWrapper<Order> wrapper = new MPJQueryWrapper<>();
|
||||
wrapper.setAlias("o");
|
||||
wrapper.leftJoin(true, " shop_goods as goods ON goods.goods_id = o.goods_id");
|
||||
wrapper.leftJoin(true, " sys_user as user ON user.user_id = o.user_id");
|
||||
wrapper.select("o.*, goods.goods_name");
|
||||
if (param.getOrderStatus() != null) {
|
||||
wrapper.eq("order_status", param.getOrderStatus());
|
||||
}
|
||||
if (param.getCreateTimeStart() != null && !param.getCreateTimeStart().isEmpty()) {
|
||||
wrapper.between("o.create_time", param.getCreateTimeStart(), param.getCreateTimeEnd());
|
||||
}
|
||||
if (param.getStoreId() != null) {
|
||||
wrapper.eq("o.store_id", param.getStoreId());
|
||||
}
|
||||
if (param.getOrgId() != null) {
|
||||
wrapper.eq("o.org_id", param.getOrgId());
|
||||
}
|
||||
if (param.getCityId() != null) {
|
||||
wrapper.eq("o.city_id", param.getCityId());
|
||||
}
|
||||
if (param.getUserId() != null) {
|
||||
wrapper.eq("o.user_id", param.getUserId());
|
||||
}
|
||||
if (param.getKeywords() != null && !param.getKeywords().isEmpty()) {
|
||||
wrapper.like("order_no", param.getKeywords())
|
||||
.or().like("user.phone", param.getKeywords())
|
||||
.or().like("user.real_name", param.getKeywords())
|
||||
.or().like("o.sku_name", param.getKeywords())
|
||||
;
|
||||
}
|
||||
if (param.getSort() == null && param.getOrder() == null) {
|
||||
wrapper.orderByDesc("o.order_id");
|
||||
} else {
|
||||
wrapper.orderBy(true, param.getOrder().equals("asc"), param.getSort());
|
||||
}
|
||||
if (param.getUserLevelList() != null && !param.getUserLevelList().isEmpty()) {
|
||||
wrapper.in("user.user_level", param.getUserLevelList());
|
||||
}
|
||||
return page(pageParam, wrapper);
|
||||
}
|
||||
|
||||
// 3.订单商户是否一致
|
||||
@Override
|
||||
public List<Order> listRel(OrderParam param) {
|
||||
List<Order> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Order, OrderParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getByIdRel(Integer orderId) {
|
||||
OrderParam param = new OrderParam();
|
||||
param.setOrderId(orderId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getByOutTradeNo(String outTradeNo) {
|
||||
OrderParam param = new OrderParam();
|
||||
param.setOrderNo(outTradeNo);
|
||||
return param.getOne(baseMapper.getOne(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付成功后处理的业务(通联支付)
|
||||
*/
|
||||
@Override
|
||||
public boolean allinPay(Map<String, String> params) {
|
||||
cacheClient.set(":payInfo", params.toString());
|
||||
final String outTradeNo = params.get("merchantOrderNo");
|
||||
final String trxamt = params.get("trxamt");
|
||||
final String merchantNo = params.get("merchantNo");
|
||||
final String chnltrxid = params.get("chnltrxid");
|
||||
final String payTime = params.get("payTime");
|
||||
final String fee = params.get("fee");
|
||||
final String trxStatus = params.get("trxstatus");
|
||||
|
||||
// 1.是否为商城订单
|
||||
Order order = orderService.getByOutTradeNo(outTradeNo);
|
||||
if (order == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2.订单金额是否一致
|
||||
final BigDecimal payPrice = new BigDecimal(trxamt).divide(new BigDecimal(100));
|
||||
|
||||
// 3.订单商户是否一致
|
||||
// if (!merchantNo.equals(order.getMerchantCode())) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// 4.验证appId是否一致
|
||||
// 4.验证appId是否一致
|
||||
// String appId = params.get("app_id");
|
||||
// System.out.println("验证appId是否一致"+appId);
|
||||
// String appIdPro = "2021003156628508";
|
||||
@@ -138,112 +175,184 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
// System.out.println("验证appId校验失败");
|
||||
// return false;
|
||||
// }
|
||||
// 5.判断交易状态
|
||||
if (!"2".equals(trxStatus)) {
|
||||
return false;
|
||||
// 5.判断交易状态
|
||||
if (!"2".equals(trxStatus)) {
|
||||
return false;
|
||||
}
|
||||
// 6.修改订单状态
|
||||
OrderParam orderParam = new OrderParam();
|
||||
orderParam.setOrderNo(outTradeNo);
|
||||
orderParam.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
orderParam.setPayPrice(payPrice);
|
||||
//
|
||||
return baseMapper.updatePayStatus(orderParam);
|
||||
}
|
||||
// 6.修改订单状态
|
||||
OrderParam orderParam = new OrderParam();
|
||||
orderParam.setOrderNo(outTradeNo);
|
||||
orderParam.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
orderParam.setPayPrice(payPrice);
|
||||
//
|
||||
return baseMapper.updatePayStatus(orderParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOrderByTimeOut() {
|
||||
final Integer pay_status = query().eq("order_no", "2023121205993791").count();
|
||||
System.out.println("处理过期订单 = " + pay_status);
|
||||
}
|
||||
@Override
|
||||
public void removeOrderByTimeOut() {
|
||||
final Integer pay_status = query().eq("order_no", "2023121205993791").count();
|
||||
System.out.println("处理过期订单 = " + pay_status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateByIdRel(Order order) {
|
||||
return baseMapper.updateByIdRel(order);
|
||||
}
|
||||
@Override
|
||||
public boolean updateByIdRel(Order order) {
|
||||
return baseMapper.updateByIdRel(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Order> selectPageSettled(OrderParam param) {
|
||||
PageParam<Order, OrderParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<Order> list = baseMapper.selectPageSettled(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
PageParam<Order, OrderParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<Order> list = baseMapper.selectPageSettled(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByIdSettled(Order order) {
|
||||
baseMapper.updateByIdSettled(order);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付成功后处理的业务
|
||||
*/
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@Override
|
||||
public void paySuccess(AlipayTradeQueryResponse params) {
|
||||
System.out.println("支付成功后处理的业务");
|
||||
String outTradeNo = params.getOutTradeNo();
|
||||
String totalAmount = params.getTotalAmount();
|
||||
String receiptAmount = params.getReceiptAmount();
|
||||
// 1.是否为商城订单
|
||||
Order order = orderService.getByOutTradeNo(outTradeNo);
|
||||
if (order == null) {
|
||||
System.out.println("订单不存在!");
|
||||
return;
|
||||
}
|
||||
// 2.订单金额是否一致
|
||||
// 3.订单商户是否一致
|
||||
// 4.验证appId是否一致
|
||||
// 5.判断交易状态
|
||||
String tradeStatus = params.getTradeStatus();
|
||||
if (!"TRADE_SUCCESS".equals(tradeStatus)) {
|
||||
System.out.println("支付未成功");
|
||||
return;
|
||||
@Override
|
||||
public Integer countNum(OrderParam param) {
|
||||
return count(
|
||||
new LambdaQueryWrapper<Order>()
|
||||
// .in(Order::getOrderStatus, 2, 3)
|
||||
.between(Order::getCreateTime, param.getCreateTimeStart(), param.getCreateTimeEnd())
|
||||
);
|
||||
}
|
||||
|
||||
// 6.修改订单状态
|
||||
order.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
order.setPayMethod(PAY_METHOD_ALIPAY);
|
||||
order.setReceiptAmount(new BigDecimal(receiptAmount));
|
||||
order.setPayTime(DateUtil.date());
|
||||
order.setExpirationTime(DateUtil.nextMonth());
|
||||
orderService.updateById(order);
|
||||
|
||||
// 6. 续租订单
|
||||
if (order.getRentOrderId() > 0) {
|
||||
// 主订单
|
||||
Order parentOrder = orderService.getById(order.getRentOrderId());
|
||||
// 更新过期时间延长一个月
|
||||
Date expirationTime = parentOrder.getExpirationTime();
|
||||
DateTime nextMonthTime = DateUtil.offsetMonth(expirationTime, 1);
|
||||
parentOrder.setExpirationTime(nextMonthTime);
|
||||
orderService.updateById(parentOrder);
|
||||
// 保存续费订单状态
|
||||
order.setDeliveryStatus(DELIVERY_STATUS_YES);
|
||||
order.setReceiptStatus(RECEIPT_STATUS_YES);
|
||||
order.setOrderStatus(ORDER_STATUS_COMPLETED);
|
||||
order.setStartTime(expirationTime);
|
||||
order.setExpirationTime(nextMonthTime);
|
||||
orderService.updateById(order);
|
||||
@Override
|
||||
public BigDecimal sumData(OrderParam param, String field) {
|
||||
Order data = getOne(
|
||||
new QueryWrapper<Order>()
|
||||
.select("SUM(`" + field + "`) AS total_amount")
|
||||
// .in("order_status", 2, 3)
|
||||
.between("create_time", param.getCreateTimeStart(), param.getCreateTimeEnd())
|
||||
);
|
||||
return data == null ? BigDecimal.ZERO : data.getTotalAmount();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询订单的关联商品
|
||||
*
|
||||
* @param orders 商品集合
|
||||
*/
|
||||
private void selectOrderGoods(List<Order> orders) {
|
||||
if (orders != null && orders.size() > 0) {
|
||||
List<Integer> orderIds = orders.stream().map(Order::getOrderId).collect(Collectors.toList());
|
||||
List<OrderGoods> orderGoods = orderGoodsService.listByOrderIds(orderIds);
|
||||
for (Order order : orders) {
|
||||
List<OrderGoods> goodsList = orderGoods.stream().filter(d -> order.getOrderId().equals(d.getOrderId()))
|
||||
.collect(Collectors.toList());
|
||||
order.setGoodsList(goodsList);
|
||||
}
|
||||
@Override
|
||||
public BigDecimal sumIncome(OrderParam param) {
|
||||
Order data = getOne(
|
||||
new QueryWrapper<Order>()
|
||||
.select("SUM(`total_price`) AS total_amount")
|
||||
.in("order_status", 2, 3)
|
||||
.between("create_time", param.getCreateTimeStart(), param.getCreateTimeEnd())
|
||||
);
|
||||
return data == null ? BigDecimal.ZERO : data.getTotalAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIncome(Order order) {
|
||||
User orderUser = userService.getById(order.getUserId());
|
||||
orderUser.setTotalIncome(orderUser.getTotalIncome().add(order.getCommission()));
|
||||
orderUser.setBalance(orderUser.getBalance().add(order.getCommission()));
|
||||
userService.updateById(orderUser);
|
||||
userBalanceLogService.save(
|
||||
new UserBalanceLog() {{
|
||||
setOrderId(order.getOrderId());
|
||||
setUserId(orderUser.getUserId());
|
||||
setScene(0);
|
||||
setMoney(order.getCommission());
|
||||
setBalance(orderUser.getBalance());
|
||||
setTenantId(10049);
|
||||
setCreateTime(DateUtil.date());
|
||||
setRemark("订单:" + order.getOrderNo() + "支付返利");
|
||||
}}
|
||||
);
|
||||
// 总售后收入
|
||||
User mainAdmin = userService.getCityLevel2(orderUser.getCityId());
|
||||
BigDecimal mainAdminIncome = order.getTotalPrice()
|
||||
.subtract(order.getCommission());
|
||||
// 售后店长提成
|
||||
// if (orderUser.getUserLevel().equals(5) || orderUser.getUserLevel().equals(8)) {
|
||||
// if (order.getFixStoreId() != 0
|
||||
// && orderUser.getFixStoreId() != null) {
|
||||
// VivoFixStore fixStore = fixStoreService.getById(orderUser.getFixStoreId());
|
||||
// if (fixStore != null) {
|
||||
// User fixStoreUser = userService.getById(fixStore.getUserId());
|
||||
// if (order.getFixStoreLeaderCommission() != null && fixStoreUser != null) {
|
||||
// fixStoreUser.setTotalIncome(fixStoreUser.getTotalIncome().add(order.getFixStoreLeaderCommission()));
|
||||
// fixStoreUser.setBalance(fixStoreUser.getBalance().add(order.getFixStoreLeaderCommission()));
|
||||
// userService.updateById(fixStoreUser);
|
||||
//
|
||||
// userBalanceLogService.save(
|
||||
// new UserBalanceLog() {{
|
||||
// setOrderId(order.getOrderId());
|
||||
// setUserId(fixStoreUser.getUserId());
|
||||
// setScene(0);
|
||||
// setMoney(order.getFixStoreLeaderCommission());
|
||||
// setBalance(fixStoreUser.getBalance());
|
||||
// setTenantId(10049);
|
||||
// setCreateTime(DateUtil.date());
|
||||
// setRemark("订单:" + order.getOrderNo() + "支付获得门店返利");
|
||||
// }}
|
||||
// );
|
||||
//
|
||||
// mainAdminIncome = mainAdminIncome.subtract(order.getFixStoreLeaderCommission());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
Goods goods = goodsService.getById(order.getGoodsId());
|
||||
mainAdminIncome = goods.getCost();
|
||||
// }
|
||||
|
||||
User cityAgent = userService.getCityAgent(orderUser.getCityId());
|
||||
if (order.getFixStoreId() == 0
|
||||
&& cityAgent != null
|
||||
&& order.getAgentCommission() != null
|
||||
&& order.getAgentCommission().compareTo(BigDecimal.ZERO) > 0) {
|
||||
cityAgent.setTotalIncome(cityAgent.getTotalIncome().add(order.getAgentCommission()));
|
||||
cityAgent.setBalance(cityAgent.getBalance().add(order.getAgentCommission()));
|
||||
userService.updateById(cityAgent);
|
||||
|
||||
userBalanceLogService.save(
|
||||
new UserBalanceLog() {{
|
||||
setOrderId(order.getOrderId());
|
||||
setUserId(cityAgent.getUserId());
|
||||
setScene(0);
|
||||
setMoney(order.getAgentCommission());
|
||||
setBalance(cityAgent.getBalance());
|
||||
setTenantId(10049);
|
||||
setCreateTime(DateUtil.date());
|
||||
setRemark("订单:" + order.getOrderNo() + "支付获得区域代理返利");
|
||||
}}
|
||||
);
|
||||
}
|
||||
|
||||
if (mainAdmin != null) {
|
||||
mainAdmin.setTotalIncome(mainAdminIncome);
|
||||
mainAdmin.setBalance(mainAdminIncome);
|
||||
userService.updateById(mainAdmin);
|
||||
BigDecimal finalMainAdminIncome = mainAdminIncome;
|
||||
userBalanceLogService.save(
|
||||
new UserBalanceLog() {{
|
||||
setOrderId(order.getOrderId());
|
||||
setUserId(mainAdmin.getUserId());
|
||||
setScene(0);
|
||||
setMoney(finalMainAdminIncome);
|
||||
setBalance(mainAdmin.getBalance());
|
||||
setTenantId(10049);
|
||||
setCreateTime(DateUtil.date());
|
||||
setRemark("订单:" + order.getOrderNo() + "支付获得总售后返利");
|
||||
}}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询订单的关联商品
|
||||
*
|
||||
* @param orders 商品集合
|
||||
*/
|
||||
private void selectOrderGoods(List<Order> orders) {
|
||||
if (orders != null && orders.size() > 0) {
|
||||
List<Integer> orderIds = orders.stream().map(Order::getOrderId).collect(Collectors.toList());
|
||||
List<OrderGoods> orderGoods = orderGoodsService.listByOrderIds(orderIds);
|
||||
for (Order order : orders) {
|
||||
List<OrderGoods> goodsList = orderGoods.stream().filter(d -> order.getOrderId().equals(d.getOrderId()))
|
||||
.collect(Collectors.toList());
|
||||
order.setGoodsList(goodsList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
||||
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.shop.mapper.PaymentMapper;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.mapper.UserBalanceLogMapper;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import com.gxwebsoft.shop.service.UserBalanceLogService;
|
||||
import com.gxwebsoft.shop.entity.UserBalanceLog;
|
||||
import com.gxwebsoft.shop.param.UserBalanceLogParam;
|
||||
@@ -9,6 +12,7 @@ import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -23,7 +27,7 @@ public class UserBalanceLogServiceImpl extends ServiceImpl<UserBalanceLogMapper,
|
||||
@Override
|
||||
public PageResult<UserBalanceLog> pageRel(UserBalanceLogParam param) {
|
||||
PageParam<UserBalanceLog, UserBalanceLogParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
page.setDefaultOrder("a.create_time desc");
|
||||
List<UserBalanceLog> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
@@ -33,7 +37,7 @@ public class UserBalanceLogServiceImpl extends ServiceImpl<UserBalanceLogMapper,
|
||||
List<UserBalanceLog> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<UserBalanceLog, UserBalanceLogParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
page.setDefaultOrder("a.create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@@ -44,4 +48,15 @@ public class UserBalanceLogServiceImpl extends ServiceImpl<UserBalanceLogMapper,
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal sumData(UserBalanceLogParam param) {
|
||||
UserBalanceLog data = getOne(
|
||||
new QueryWrapper<UserBalanceLog>()
|
||||
.select("SUM(`money`) AS total_amount")
|
||||
.eq("scene", param.getScene())
|
||||
.between("create_time", param.getCreateTimeStart(), param.getCreateTimeEnd())
|
||||
);
|
||||
return data == null ? BigDecimal.ZERO : data.getTotalAmount();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user