From 2af6d62737bc0289198432127674006c72382756 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Fri, 13 Sep 2024 10:08:18 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E9=A3=9E=E9=B9=85=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=9C=BA=E6=89=93=E5=8D=B0=E8=8F=9C=E5=93=81=E5=B0=8F=E7=A5=A8?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E4=BD=BF=E7=94=A8=E7=B1=BB=E5=9E=8B=E5=8C=BA?= =?UTF-8?q?=E5=88=86type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/rabbit/PrintMechineConsumer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java index a60b8a0..e867773 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java @@ -674,7 +674,9 @@ public class PrintMechineConsumer { break; case "one": //一菜一品 - if (!orderInfo.getStatus().equals("unpaid")) { + if (orderInfo.getPayType() != null + && "postPay".equals(orderInfo.getPayType()) + && !orderInfo.getStatus().equals("unpaid")) { return; } From a84f3f39b361f5cd7b577385552f8024360572b2 Mon Sep 17 00:00:00 2001 From: yijiegong Date: Sat, 14 Sep 2024 18:04:47 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=91=98=E5=B7=A5?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StaffPermissionController.java | 25 ++++ .../dao/TbShopPermissionDao.java | 15 ++ .../dao/TbShopStaffPermissionDao.java | 15 ++ .../entity/TbShopPermission.java | 129 ++++++++++++++++++ .../entity/TbShopStaffPermission.java | 77 +++++++++++ .../service/TbShopPermissionService.java | 21 +++ .../service/TbShopStaffPermissionService.java | 15 ++ .../impl/TbShopPermissionServiceImpl.java | 46 +++++++ .../TbShopStaffPermissionServiceImpl.java | 21 +++ .../cashierservice/StaffPermissionTest.java | 22 +++ 10 files changed, 386 insertions(+) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/controller/StaffPermissionController.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopPermissionDao.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopStaffPermissionDao.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopPermission.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopStaffPermission.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopPermissionService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopStaffPermissionService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopPermissionServiceImpl.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopStaffPermissionServiceImpl.java create mode 100644 src/test/java/com/chaozhanggui/system/cashierservice/StaffPermissionTest.java diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/StaffPermissionController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/StaffPermissionController.java new file mode 100644 index 0000000..98a2b89 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/StaffPermissionController.java @@ -0,0 +1,25 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.service.TbShopPermissionService; +import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService; +import com.chaozhanggui.system.cashierservice.sign.Result; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Slf4j +@RequestMapping("staffPermission") +public class StaffPermissionController { + + @Autowired + private TbShopPermissionService permissionService; + + @GetMapping + public Result getStaffPermission(String staffId, String code) { + return permissionService.getStaffPermission(staffId, code); + } + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopPermissionDao.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopPermissionDao.java new file mode 100644 index 0000000..664e64c --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopPermissionDao.java @@ -0,0 +1,15 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbShopPermission; + +/** + * (TbShopPermission)表数据库访问层 + * + * @author makejava + * @since 2024-09-14 17:08:48 + */ +public interface TbShopPermissionDao extends BaseMapper { + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopStaffPermissionDao.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopStaffPermissionDao.java new file mode 100644 index 0000000..a536686 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopStaffPermissionDao.java @@ -0,0 +1,15 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission; + +/** + * 店铺员工权限关联表(TbShopStaffPermission)表数据库访问层 + * + * @author makejava + * @since 2024-09-14 17:07:33 + */ +public interface TbShopStaffPermissionDao extends BaseMapper { + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopPermission.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopPermission.java new file mode 100644 index 0000000..380a643 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopPermission.java @@ -0,0 +1,129 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.extension.activerecord.Model; + +import java.io.Serializable; + +/** + * (TbShopPermission)表实体类 + * + * @author makejava + * @since 2024-09-14 17:08:48 + */ +@SuppressWarnings("serial") +public class TbShopPermission extends Model { + + private Integer id; + //权限类型:staff 员工, + private String type; + //权限名称 + private String label; + //权限code,为了区分采用汉语拼音 + private String code; + //层级 + private Integer level; + //上级ID + private Integer parentId; + //是否重要: 重要对应页面红色 + private Integer isImportant; + //排序 + private Integer sort; + + private Date createTime; + + private Date updateTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + public Integer getParentId() { + return parentId; + } + + public void setParentId(Integer parentId) { + this.parentId = parentId; + } + + public Integer getIsImportant() { + return isImportant; + } + + public void setIsImportant(Integer isImportant) { + this.isImportant = isImportant; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopStaffPermission.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopStaffPermission.java new file mode 100644 index 0000000..46c4a31 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopStaffPermission.java @@ -0,0 +1,77 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import com.baomidou.mybatisplus.extension.activerecord.Model; + +import java.io.Serializable; + +/** + * 店铺员工权限关联表(TbShopStaffPermission)表实体类 + * + * @author makejava + * @since 2024-09-14 17:07:33 + */ +@SuppressWarnings("serial") +public class TbShopStaffPermission extends Model { + + private Integer id; + //权限ID + private Integer permissionId; + //员工ID + private Integer staffId; + //店铺ID + private Integer shopId; + //用户ID + private Integer userId; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getPermissionId() { + return permissionId; + } + + public void setPermissionId(Integer permissionId) { + this.permissionId = permissionId; + } + + public Integer getStaffId() { + return staffId; + } + + public void setStaffId(Integer staffId) { + this.staffId = staffId; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopPermissionService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopPermissionService.java new file mode 100644 index 0000000..9fb6a38 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopPermissionService.java @@ -0,0 +1,21 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.chaozhanggui.system.cashierservice.entity.TbShopPermission; +import com.chaozhanggui.system.cashierservice.sign.Result; + +/** + * (TbShopPermission)表服务接口 + * + * @author makejava + * @since 2024-09-14 17:08:48 + */ +public interface TbShopPermissionService extends IService { + + /** + * 查询员工是否拥有某个权限 + */ + Result getStaffPermission(String staffId, String code); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopStaffPermissionService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopStaffPermissionService.java new file mode 100644 index 0000000..e6da0ac --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopStaffPermissionService.java @@ -0,0 +1,15 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission; + +/** + * 店铺员工权限关联表(TbShopStaffPermission)表服务接口 + * + * @author makejava + * @since 2024-09-14 17:07:33 + */ +public interface TbShopStaffPermissionService extends IService { + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopPermissionServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopPermissionServiceImpl.java new file mode 100644 index 0000000..686eac0 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopPermissionServiceImpl.java @@ -0,0 +1,46 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chaozhanggui.system.cashierservice.dao.TbShopPermissionDao; +import com.chaozhanggui.system.cashierservice.entity.TbShopPermission; +import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission; +import com.chaozhanggui.system.cashierservice.service.TbShopPermissionService; +import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +/** + * (TbShopPermission)表服务实现类 + * + * @author makejava + * @since 2024-09-14 17:08:49 + */ +@Service +@Primary +public class TbShopPermissionServiceImpl extends ServiceImpl implements TbShopPermissionService { + + @Autowired + private TbShopStaffPermissionService shopStaffPermissionService; + + @Override + public Result getStaffPermission(String staffId, String code) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("code", code); + TbShopPermission permission = this.getOne(queryWrapper); + if (permission == null) { + return Result.fail("权限不存在"); + } + + QueryWrapper staffPermissionQueryWrapper = new QueryWrapper<>(); + staffPermissionQueryWrapper.eq("staff_id", staffId); + staffPermissionQueryWrapper.eq("permission_id", permission.getId()); + TbShopStaffPermission staffPermission = shopStaffPermissionService.getOne(staffPermissionQueryWrapper); + + return Result.success(CodeEnum.SUCCESS, staffPermission != null); + } +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopStaffPermissionServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopStaffPermissionServiceImpl.java new file mode 100644 index 0000000..19af549 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopStaffPermissionServiceImpl.java @@ -0,0 +1,21 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chaozhanggui.system.cashierservice.dao.TbShopStaffPermissionDao; +import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission; +import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +/** + * 店铺员工权限关联表(TbShopStaffPermission)表服务实现类 + * + * @author makejava + * @since 2024-09-14 17:07:33 + */ +@Service +@Primary +public class TbShopStaffPermissionServiceImpl extends ServiceImpl implements TbShopStaffPermissionService { + +} + diff --git a/src/test/java/com/chaozhanggui/system/cashierservice/StaffPermissionTest.java b/src/test/java/com/chaozhanggui/system/cashierservice/StaffPermissionTest.java new file mode 100644 index 0000000..302aed4 --- /dev/null +++ b/src/test/java/com/chaozhanggui/system/cashierservice/StaffPermissionTest.java @@ -0,0 +1,22 @@ +package com.chaozhanggui.system.cashierservice; + +import com.chaozhanggui.system.cashierservice.service.TbShopPermissionService; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +@ActiveProfiles("dev") +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class StaffPermissionTest { + @Autowired + private TbShopPermissionService tbShopPermissionService; + @Test + public void testStaffPermission() { + + Result yunXuTuiKuan = tbShopPermissionService.getStaffPermission("128", "yun_xu_tui_kuan2"); + System.out.println(yunXuTuiKuan); + + } +} From 4ee6999b167dd5330d102d24f66097e94361c2a5 Mon Sep 17 00:00:00 2001 From: yijiegong Date: Sun, 15 Sep 2024 19:26:42 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E8=80=97=E6=9D=90=E6=B6=88=E8=80=97=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E4=B8=8D=E7=AE=A1=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=BA=93=E5=AD=98=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/ConsService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java index 879a464..546ab2b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java @@ -66,8 +66,8 @@ public class ConsService { List consInfoFlows=new ArrayList<>(); for (TbOrderDetail orderDetail : orderDetails) { -// List proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId()); - List proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductIdAndCheck(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId()); + List proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId()); +// List proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductIdAndCheck(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId()); if(Objects.isNull(proskuCons)||proskuCons.size()<=0){ log.info("耗材信息未配置或未开启校验:orderId:{},skuId:{},shopId:{},productId:{}",orderDetail.getOrderId(),orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId()); continue; From 53597281d9bf682ac67f95c67f09e74a00ec5e91 Mon Sep 17 00:00:00 2001 From: yijiegong Date: Wed, 18 Sep 2024 17:42:42 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=AE=9D=E6=94=AF=E4=BB=98=20=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/PayService.java | 17 ++++++++++------- .../thirdpay/service/ThirdPayService.java | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index 00373d7..68679b3 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -1860,10 +1860,9 @@ public class PayService { public Result createOrder(String ip, String userId, String payType, String shopId, BigDecimal amount) throws JsonProcessingException { - if (ObjectUtil.isNull(userId) || ObjectUtil.isEmpty(userId) || ObjectUtil.isEmpty(payType) || ObjectUtil.isNull(payType) - - || ObjectUtil.isNull(shopId) || ObjectUtil.isEmpty(shopId) || ObjectUtil.isNull(shopId) || ObjectUtil.isNull(amount) || ObjectUtil.isEmpty(amount) - ) { + if (ObjectUtil.isNull(userId) || ObjectUtil.isEmpty(userId) || ObjectUtil.isEmpty(payType) || + ObjectUtil.isNull(payType) || ObjectUtil.isNull(shopId) || ObjectUtil.isEmpty(shopId) || + ObjectUtil.isNull(shopId) || ObjectUtil.isNull(amount) || ObjectUtil.isEmpty(amount)) { return Result.fail(CodeEnum.PARAM); } @@ -1930,8 +1929,10 @@ public class PayService { String reqbody = "店铺收款码"; if("WECHAT".equals(payType)){ - PublicResp publicResp = thirdPayService.jspay(url, thirdApply.getAppId(), thirdApply.getAppToken(), reqbody, reqbody, orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(), payType, "WECHAT".equals(payType) ? thirdApply.getSmallAppid() : null, userId, ip, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), backUrl, backUrl); - + PublicResp publicResp = thirdPayService.jspay(url, thirdApply.getAppId(), thirdApply.getAppToken(), + reqbody, reqbody, orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(), + payType, thirdApply.getSmallAppid(), userId, ip, + DateUtils.getSsdfTimes(), thirdApply.getStoreId(), backUrl, backUrl); if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { if ("000000".equals(publicResp.getCode())) { @@ -1981,7 +1982,9 @@ public class PayService { } } }else if("ALIPAY".equals(payType)){ - PublicResp publicResp= thirdPayService.apppay(url,thirdApply.getAppId(),thirdApply.getAppToken(),reqbody,reqbody,orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(),payType,ip,DateUtils.getSsdfTimes(),thirdApply.getStoreId(),backUrl,backUrl); + PublicResp publicResp= thirdPayService.apppay(url,thirdApply.getAppId(),thirdApply.getAppToken(), + reqbody,reqbody,orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(), + payType,ip,DateUtils.getSsdfTimes(),thirdApply.getStoreId(),backUrl,backUrl); if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { if ("000000".equals(publicResp.getCode())) { diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java index e588ff6..312909b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java @@ -411,7 +411,7 @@ public class ThirdPayService { param.setSign(sign); String reqbody = JSONUtil.toJSONString(param); log.info("请求参数:{}", reqbody); - String response = HttpRequest.post(url.concat(apppay)).body(reqbody).execute().body(); + String response = HttpRequest.post(url.concat(h5pay)).body(reqbody).execute().body(); log.info("返回结果:{}", response); PublicResp resp =JSONUtil.parseJSONStr2T(response,PublicResp.class); resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),ApppayResp.class)); From 46205fb7ce41044b7fa00520d809f1db7611f2cd Mon Sep 17 00:00:00 2001 From: yijiegong Date: Wed, 18 Sep 2024 17:48:29 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=AE=9D=E6=94=AF=E4=BB=98=20=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chaozhanggui/system/cashierservice/service/PayService.java | 2 +- .../system/cashierservice/thirdpay/service/ThirdPayService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index 68679b3..1ea68a8 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -1928,7 +1928,7 @@ public class PayService { String reqbody = "店铺收款码"; - if("WECHAT".equals(payType)){ + if("WECHAT".equals(payType) || "ALIPAY".equals(payType)){ PublicResp publicResp = thirdPayService.jspay(url, thirdApply.getAppId(), thirdApply.getAppToken(), reqbody, reqbody, orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(), payType, thirdApply.getSmallAppid(), userId, ip, diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java index 312909b..e588ff6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java @@ -411,7 +411,7 @@ public class ThirdPayService { param.setSign(sign); String reqbody = JSONUtil.toJSONString(param); log.info("请求参数:{}", reqbody); - String response = HttpRequest.post(url.concat(h5pay)).body(reqbody).execute().body(); + String response = HttpRequest.post(url.concat(apppay)).body(reqbody).execute().body(); log.info("返回结果:{}", response); PublicResp resp =JSONUtil.parseJSONStr2T(response,PublicResp.class); resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),ApppayResp.class)); From d7f2d5afc1eaee5cf351ed7d5896d0879f2f1f55 Mon Sep 17 00:00:00 2001 From: yijiegong Date: Wed, 18 Sep 2024 18:17:28 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=AE=9D=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/PayService.java | 130 +++++------------- .../thirdpay/service/ThirdPayService.java | 10 +- 2 files changed, 42 insertions(+), 98 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index 1ea68a8..2f346b9 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -1545,17 +1545,13 @@ public class PayService { if (ObjectUtil.isNotNull(orderstatus) && ObjectUtil.isNotEmpty(orderstatus)) { if ("000000".equals(orderstatus.getCode())) { if ("TRADE_SUCCESS".equals(orderstatus.getObjData().getState())) { - tbQuickPay.setStatus("0"); tbQuickPay.setUpdateTime(new Date()); tbQuickPayMapper.updateByPrimaryKeySelective(tbQuickPay); } - - } } } - } return Result.success(CodeEnum.SUCCESS, tbQuickPay); @@ -1927,115 +1923,59 @@ public class PayService { } String reqbody = "店铺收款码"; + PublicResp publicResp = thirdPayService.jspay(url, thirdApply.getAppId(), thirdApply.getAppToken(), + reqbody, reqbody, orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(), + payType, thirdApply.getSmallAppid(), userId, ip, + DateUtils.getSsdfTimes(), thirdApply.getStoreId(), backUrl, backUrl); - if("WECHAT".equals(payType) || "ALIPAY".equals(payType)){ - PublicResp publicResp = thirdPayService.jspay(url, thirdApply.getAppId(), thirdApply.getAppToken(), - reqbody, reqbody, orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(), - payType, thirdApply.getSmallAppid(), userId, ip, - DateUtils.getSsdfTimes(), thirdApply.getStoreId(), backUrl, backUrl); + if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { + if ("000000".equals(publicResp.getCode())) { + JspayResp scanpayResp = publicResp.getObjData(); + if ("TRADE_SUCCESS".equals(scanpayResp.getState())) { - if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { - if ("000000".equals(publicResp.getCode())) { - JspayResp scanpayResp = publicResp.getObjData(); - if ("TRADE_SUCCESS".equals(scanpayResp.getState())) { + payment.setTradeNumber(scanpayResp.getPayOrderId()); + payment.setUpdatedAt(System.currentTimeMillis()); + tbOrderPaymentMapper.updateByPrimaryKeySelective(payment); - payment.setTradeNumber(scanpayResp.getPayOrderId()); - payment.setUpdatedAt(System.currentTimeMillis()); - tbOrderPaymentMapper.updateByPrimaryKeySelective(payment); - - //处理支付成功的订单 - orderInfo.setStatus("closed"); - orderInfo.setPayOrderNo(scanpayResp.getPayOrderId()); - tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); + //处理支付成功的订单 + orderInfo.setStatus("closed"); + orderInfo.setPayOrderNo(scanpayResp.getPayOrderId()); + tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); - ObjectMapper mapper = new ObjectMapper(); - return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo())); + ObjectMapper mapper = new ObjectMapper(); + return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo())); - } else if ("TRADE_AWAIT".equals(scanpayResp.getState())) { - orderInfo.setStatus("paying"); - orderInfo.setPayOrderNo(payment.getTradeNumber()); - tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); + } else if ("TRADE_AWAIT".equals(scanpayResp.getState())) { + orderInfo.setStatus("paying"); + orderInfo.setPayOrderNo(payment.getTradeNumber()); + tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); - payment.setTradeNumber(scanpayResp.getPayOrderId()); - payment.setUpdatedAt(System.currentTimeMillis()); - tbOrderPaymentMapper.updateByPrimaryKeySelective(payment); + payment.setTradeNumber(scanpayResp.getPayOrderId()); + payment.setUpdatedAt(System.currentTimeMillis()); + tbOrderPaymentMapper.updateByPrimaryKeySelective(payment); - if ("WECHAT".equals(scanpayResp.getPayType())) { - orderInfo.setPayType("WECHAT"); - } else if ("ALIPAY".equals(scanpayResp.getPayType())) { - orderInfo.setPayType("ALIPAY"); - } else if ("UNIONPAY".equals(scanpayResp.getPayType())) { - orderInfo.setPayType("UNIONPAY"); - } - - - ObjectMapper mapper = new ObjectMapper(); - - Map map=new HashMap<>(); - - map.put("orderInfo",orderInfo); - map.put("payInfo",mapper.readTree(scanpayResp.getPayInfo())); - return Result.success(CodeEnum.PAYING, map); + if ("WECHAT".equals(scanpayResp.getPayType())) { + orderInfo.setPayType("WECHAT"); + } else if ("ALIPAY".equals(scanpayResp.getPayType())) { + orderInfo.setPayType("ALIPAY"); + } else if ("UNIONPAY".equals(scanpayResp.getPayType())) { + orderInfo.setPayType("UNIONPAY"); } - } - } - }else if("ALIPAY".equals(payType)){ - PublicResp publicResp= thirdPayService.apppay(url,thirdApply.getAppId(),thirdApply.getAppToken(), - reqbody,reqbody,orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(), - payType,ip,DateUtils.getSsdfTimes(),thirdApply.getStoreId(),backUrl,backUrl); - - if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { - if ("000000".equals(publicResp.getCode())) { - ApppayResp scanpayResp = publicResp.getObjData(); - if ("TRADE_SUCCESS".equals(scanpayResp.getState())) { - - payment.setTradeNumber(scanpayResp.getPayOrderId()); - payment.setUpdatedAt(System.currentTimeMillis()); - tbOrderPaymentMapper.updateByPrimaryKeySelective(payment); - - //处理支付成功的订单 - orderInfo.setStatus("closed"); - orderInfo.setPayOrderNo(scanpayResp.getPayOrderId()); - tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); - ObjectMapper mapper = new ObjectMapper(); - return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo())); + ObjectMapper mapper = new ObjectMapper(); - } else if ("TRADE_AWAIT".equals(scanpayResp.getState())) { - orderInfo.setStatus("paying"); - orderInfo.setPayOrderNo(payment.getTradeNumber()); - tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); + Map map=new HashMap<>(); - payment.setTradeNumber(scanpayResp.getPayOrderId()); - payment.setUpdatedAt(System.currentTimeMillis()); - tbOrderPaymentMapper.updateByPrimaryKeySelective(payment); - - - if ("WECHAT".equals(scanpayResp.getPayType())) { - orderInfo.setPayType("WECHAT"); - } else if ("ALIPAY".equals(scanpayResp.getPayType())) { - orderInfo.setPayType("ALIPAY"); - } else if ("UNIONPAY".equals(scanpayResp.getPayType())) { - orderInfo.setPayType("UNIONPAY"); - } - - - ObjectMapper mapper = new ObjectMapper(); - - Map map=new HashMap<>(); - - map.put("orderInfo",orderInfo); - map.put("payInfo",mapper.readTree(scanpayResp.getPayInfo())); - return Result.success(CodeEnum.PAYING, map); - } + map.put("orderInfo",orderInfo); + map.put("payInfo",mapper.readTree(scanpayResp.getPayInfo())); + return Result.success(CodeEnum.PAYING, map); } } } - return Result.fail(CodeEnum.FAIL); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java index e588ff6..adc6d43 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/thirdpay/service/ThirdPayService.java @@ -197,9 +197,13 @@ public class ThirdPayService { * @param key * @return */ - public PublicResp returnOrder(String url,String appId, String mchRefundNo, String payOrderId, String mchOrderNo, String refundReason, Long refundAmount, String notifyUrl, String extParam,String key){ - OrderRefundReq req=new OrderRefundReq(mchRefundNo, payOrderId, mchOrderNo, refundReason, refundAmount, notifyUrl, extParam); - PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis())); + public PublicResp returnOrder(String url,String appId, String mchRefundNo, String payOrderId, + String mchOrderNo, String refundReason, Long refundAmount, + String notifyUrl, String extParam,String key){ + OrderRefundReq req=new OrderRefundReq(mchRefundNo, payOrderId, mchOrderNo, refundReason, refundAmount, + notifyUrl, extParam); + PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(), + "1.0", String.valueOf(System.currentTimeMillis())); try { String str = JSONUtil.toJSONString(sortFields(req)); param.setBizData(str); From f768f7f473a89b1e96e90aeafa6f4c30bbd6122b Mon Sep 17 00:00:00 2001 From: yijiegong Date: Thu, 19 Sep 2024 09:54:00 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=94=B6=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PayController.java | 224 ++++++++---------- .../cashierservice/model/PaymentReq.java | 3 - .../cashierservice/service/PayService.java | 51 ++-- 3 files changed, 127 insertions(+), 151 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java index 1bbec3e..2d24a3d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java @@ -1,6 +1,7 @@ package com.chaozhanggui.system.cashierservice.controller; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayClient; @@ -11,11 +12,14 @@ import com.alipay.api.request.AlipayUserInfoShareRequest; import com.alipay.api.response.AlipaySystemOauthTokenResponse; import com.alipay.api.response.AlipayUserInfoShareResponse; import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit; +import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper; import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail; +import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto; import com.chaozhanggui.system.cashierservice.entity.dto.VipPayDTO; import com.chaozhanggui.system.cashierservice.model.PaymentReq; import com.chaozhanggui.system.cashierservice.service.PayService; +import com.chaozhanggui.system.cashierservice.service.ShopInfoService; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.util.IpUtil; @@ -32,7 +36,9 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.time.LocalDate; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; @CrossOrigin(origins = "*") @@ -40,26 +46,26 @@ import java.util.Objects; @Slf4j @RequestMapping("pay") public class PayController { - - @Autowired PayService payService; + @Autowired + private ShopInfoService shopInfoService; - + @Autowired + TbShopInfoMapper tbShopInfoMapper; @RequestMapping("queryPayType") - public Result queryPayType( @RequestHeader("token") String token, - @RequestHeader("loginName") String loginName, - @RequestHeader("clientType") String clientType, - @RequestParam("shopId") String shopId - - ){ + public Result queryPayType(@RequestHeader("token") String token, + @RequestHeader("loginName") String loginName, + @RequestHeader("clientType") String clientType, + @RequestParam("shopId") String shopId) { return payService.queryPayType(shopId); } /** * 扫码支付 + * * @param request * @param token * @param loginName @@ -72,56 +78,55 @@ public class PayController { @RequestHeader("token") String token, @RequestHeader("loginName") String loginName, @RequestHeader("clientType") String clientType, - @RequestBody PaymentReq paymentReq - ) { - return payService.scanPay(paymentReq.getOrderId(),paymentReq.getAuthCode(), IpUtil.getIpAddr(request),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount()); + @RequestBody PaymentReq paymentReq) { + return payService.scanPay(paymentReq.getOrderId(), paymentReq.getAuthCode(), IpUtil.getIpAddr(request), token, paymentReq.getPayAmount(), paymentReq.getDiscountAmount()); } /** * 储值卡支付 + * * @param token * @param loginName * @param clientType * @return */ - @RequestMapping("accountPay") @LimitSubmit(key = "accountPay:%s") public Result accountPay(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, @RequestHeader("clientType") String clientType, - @RequestBody PaymentReq paymentReq - ){ - return payService.accountPay(paymentReq.getOrderId(),paymentReq.getMemberId(),token,paymentReq.getMemberAccount(),paymentReq.getPayAmount(),paymentReq.getDiscountAmount()); + @RequestBody PaymentReq paymentReq) { + return payService.accountPay(paymentReq.getOrderId(), paymentReq.getMemberId(), token, paymentReq.getMemberAccount(), paymentReq.getPayAmount(), paymentReq.getDiscountAmount()); } /** * 快捷收款 + * * @param token * @param loginName * @param clientType * @param amount * @param authCode - * @param payType cash 现金 scanpay 扫码 + * @param payType cash 现金 scanpay 扫码 * @return */ @GetMapping("quickPay") @LimitSubmit(key = "quickPay:%s") public Result quickPay(@RequestHeader("token") String token, - @RequestHeader("loginName") String loginName, - @RequestHeader("clientType") String clientType, - @RequestParam("amount") String amount, - @RequestParam("authCode") String authCode, - @RequestParam("payType") String payType - ){ - return payService.quickPay(token,amount,authCode,payType); + @RequestHeader("loginName") String loginName, + @RequestHeader("clientType") String clientType, + @RequestParam("amount") String amount, + @RequestParam("authCode") String authCode, + @RequestParam("payType") String payType) { + return payService.quickPay(token, amount, authCode, payType); } /** * 查询快捷订单状态 + * * @param token * @param loginName * @param clientType @@ -129,16 +134,16 @@ public class PayController { */ @GetMapping("queryQuickPayStatus") public Result queryQuickPayStatus(@RequestHeader("token") String token, - @RequestHeader("loginName") String loginName, - @RequestHeader("clientType") String clientType, - @RequestParam("orderId") String orderId - ){ + @RequestHeader("loginName") String loginName, + @RequestHeader("clientType") String clientType, + @RequestParam("orderId") String orderId) { return payService.queryQuickPayStatus(orderId); } /** * 获取快捷收款信息 + * * @param token * @param loginName * @param clientType @@ -148,21 +153,16 @@ public class PayController { */ @GetMapping("queryQuickPay") public Result queryQuickPay(@RequestHeader("token") String token, - @RequestHeader("loginName") String loginName, - @RequestHeader("clientType") String clientType, - @RequestParam("page") Integer page, - @RequestParam("pageSize") Integer pageSize - ){ - return payService.queryQuickPay(token,page,pageSize); + @RequestHeader("loginName") String loginName, + @RequestHeader("clientType") String clientType, + @RequestParam("page") Integer page, + @RequestParam("pageSize") Integer pageSize) { + return payService.queryQuickPay(token, page, pageSize); } - - - - - /** * 会员扫码支付 + * * @param token * @param loginName * @param clientType @@ -171,17 +171,16 @@ public class PayController { @RequestMapping("memberScanPay") @LimitSubmit(key = "memberScanPay:%s") public Result memberScanPay(@RequestHeader("token") String token, - @RequestHeader("loginName") String loginName, - @RequestHeader("clientType") String clientType, - @RequestBody PaymentReq paymentReq - ){ - return payService.memberScanPay(paymentReq.getOrderId(),paymentReq.getMemberCode(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount()); + @RequestHeader("loginName") String loginName, + @RequestHeader("clientType") String clientType, + @RequestBody PaymentReq paymentReq) { + return payService.memberScanPay(paymentReq.getOrderId(), paymentReq.getMemberCode(), token, paymentReq.getPayAmount(), paymentReq.getDiscountAmount()); } - /** * 现金支付 + * * @param token * @param loginName * @param clientType @@ -192,14 +191,14 @@ public class PayController { public Result cashPay(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, @RequestHeader("clientType") String clientType, - @RequestBody PaymentReq paymentReq){ + @RequestBody PaymentReq paymentReq) { Result result = payService.cashPay(paymentReq.getOrderId(), token, paymentReq.getPayAmount(), paymentReq.getDiscountAmount()); return result; } - /** * 会员支付 + * * @param token * @param loginName * @param clientType @@ -208,29 +207,23 @@ public class PayController { @PostMapping("vipPay") @LimitSubmit(key = "vipPay:%s") public Result vipPay(@RequestHeader("token") String token, - @RequestHeader("loginName") String loginName, - @RequestHeader("clientType") String clientType, - @RequestBody VipPayDTO vipPayDTO - ){ + @RequestHeader("loginName") String loginName, + @RequestHeader("clientType") String clientType, + @RequestBody VipPayDTO vipPayDTO) { if (vipPayDTO.getOrderId() == null || vipPayDTO.getVipUserId() == null) { return Result.fail("参数缺失"); } - if ( - (vipPayDTO.getPayAmount() != null && vipPayDTO.getPayAmount().compareTo(BigDecimal.ZERO) <= 0) || - (vipPayDTO.getDiscountAmount() != null && vipPayDTO.getDiscountAmount().compareTo(BigDecimal.ZERO) <= 0) - ) { + if ((vipPayDTO.getPayAmount() != null && vipPayDTO.getPayAmount().compareTo(BigDecimal.ZERO) <= 0) || + (vipPayDTO.getDiscountAmount() != null && vipPayDTO.getDiscountAmount().compareTo(BigDecimal.ZERO) <= 0)) { return Result.fail("折扣金额必须大于0"); } - return payService.vipPay(vipPayDTO.getOrderId(),token, vipPayDTO.getVipUserId(), vipPayDTO.getPayAmount(), vipPayDTO.getDiscountAmount()); + return payService.vipPay(vipPayDTO.getOrderId(), token, vipPayDTO.getVipUserId(), vipPayDTO.getPayAmount(), vipPayDTO.getDiscountAmount()); } - - - - /** * 银行卡支付 + * * @param token * @param loginName * @param clientType @@ -241,12 +234,10 @@ public class PayController { public Result bankPay(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, @RequestHeader("clientType") String clientType, - @RequestBody PaymentReq paymentReq){ - return payService.bankPay(paymentReq.getOrderId(),token,paymentReq.getPayAmount(),paymentReq.getDiscountAmount()); + @RequestBody PaymentReq paymentReq) { + return payService.bankPay(paymentReq.getOrderId(), token, paymentReq.getPayAmount(), paymentReq.getDiscountAmount()); } - - @RequestMapping("returnOrder") @LimitSubmit(key = "returnOrder:%s", limit = 10) public Result returnOrder(@RequestHeader("token") String token, @@ -254,12 +245,8 @@ public class PayController { @RequestHeader("clientType") String clientType, @RequestBody List list, @RequestParam("pwd") String pwd, - @RequestParam(defaultValue = "true") boolean isOnline - ){ - - - - return payService.returnOrder(list,token,pwd, isOnline); + @RequestParam(defaultValue = "true") boolean isOnline) { + return payService.returnOrder(list, token, pwd, isOnline); } @@ -267,55 +254,46 @@ public class PayController { public Result queryOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, @RequestHeader("clientType") String clientType, - @RequestParam("orderId") String orderId){ - return payService.queryOrder(orderId,token); + @RequestParam("orderId") String orderId) { + return payService.queryOrder(orderId, token); } @RequestMapping("returnGpOrder") - public Result returnOrder(@RequestBody ReturnGroupOrderDto param){ + public Result returnOrder(@RequestBody ReturnGroupOrderDto param) { return payService.returnGroupOrder(param); } - @RequestMapping("test") @LimitSubmit(key = "testOrder:%s") - public Result testOrder( @RequestParam("orderId") String orderId){ + public Result testOrder(@RequestParam("orderId") String orderId) { return Result.success(CodeEnum.SUCCESS); } - - @RequestMapping("getOrderDiscount") public Result getOrderDiscount(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, @RequestHeader("clientType") String clientType, @RequestParam("orderId") String orderId, - @RequestParam("staffId") String staffId - ){ + @RequestParam("staffId") String staffId) { return payService.getOrderDiscount(staffId, orderId, token); } - @RequestMapping("pcscanpay") @LimitSubmit(key = "pcscanpay:%s") - public Result pcscanpay(HttpServletRequest request,@RequestBody PaymentReq paymentReq){ + public Result pcscanpay(HttpServletRequest request, @RequestBody PaymentReq paymentReq) { try { - return payService.pcscanpay(paymentReq.getOrderId(),IpUtil.getIpAddr(request),paymentReq.getUserId(),paymentReq.getPayType()); + return payService.pcscanpay(paymentReq.getOrderId(), IpUtil.getIpAddr(request), paymentReq.getUserId(), paymentReq.getPayType()); } catch (Exception e) { e.printStackTrace(); } return Result.fail(CodeEnum.FAIL); } - - - - - @RequestMapping("createOrder") - public Result createOrder(HttpServletRequest request,@RequestBody PaymentReq paymentReq){ + public Result createOrder(HttpServletRequest request, @RequestBody PaymentReq paymentReq) { try { - return payService.createOrder(IpUtil.getIpAddr(request),paymentReq.getUserId(),paymentReq.getPayType(),paymentReq.getShopId(),paymentReq.getPayAmount()); + return payService.createOrder(IpUtil.getIpAddr(request), paymentReq.getUserId(), paymentReq.getPayType(), + paymentReq.getShopId(), paymentReq.getOrderId(), paymentReq.getPayAmount()); } catch (JsonProcessingException e) { e.printStackTrace(); } @@ -324,24 +302,16 @@ public class PayController { } @GetMapping("queryOrderPay") - public Result queryOrderPay(String orderId){ + public Result queryOrderPay(String orderId) { return payService.queryOrderPay(orderId); } - - - - - - @Value("${wx.ysk.appId}") private String appId; @Value("${wx.ysk.secrete}") private String secrete; - - @Value("${ali.appId}") private String aliAppId; @@ -352,39 +322,45 @@ public class PayController { private String publicKey; - /** * 获取支付宝或微信openId + * * @param code * @return */ @GetMapping("/openId") - public Result getOpenId( - @RequestParam String code, - @RequestParam String payType - ) throws AlipayApiException { + public Result getOpenId(@RequestParam String code, @RequestParam String payType, + @RequestParam String shopId) throws AlipayApiException { + if (StrUtil.isBlank(shopId)) { + return Result.fail("店铺ID不能为空"); + } - if("WECHAT".equals(payType)){ + // 查询店铺信息 + TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId)); + if (Objects.isNull(shopInfo)) { + return Result.fail("店铺不存在"); + } + + Map data = new HashMap<>(4); + data.put("shopId", shopInfo.getId()); + data.put("shopName", shopInfo.getShopName()); + data.put("shopImage", shopInfo.getCoverImg()); + + if ("WECHAT".equals(payType)) { JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, appId, secrete); - log.info("SessionKeyOpenId:{}",SessionKeyOpenId.toString()); + log.info("SessionKeyOpenId:{}", SessionKeyOpenId.toString()); String openid = SessionKeyOpenId.getString("openid"); - if(Objects.isNull(openid)){ + if (Objects.isNull(openid)) { return Result.fail("获取微信id失败"); } - return Result.success(CodeEnum.SUCCESS,openid); - }else if("ALIPAY".equals(payType)){ - - + data.put("openId", openid); + return Result.success(CodeEnum.SUCCESS, data); + } else if ("ALIPAY".equals(payType)) { // 初始化SDK AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig()); - // 构造请求参数以调用接口 AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest(); - - // 设置刷新令牌 -// request.setRefreshToken("201208134b203fe6c11548bcabd8da5bb087a83b"); - // 设置授权码 request.setCode(code); @@ -400,15 +376,17 @@ public class PayController { return Result.fail("获取支付宝userId失败"); } - return Result.success(CodeEnum.SUCCESS, ObjectUtil.isNull(response.getUserId())?response.getOpenId():response.getUserId()); + String openid = ObjectUtil.isNull(response.getUserId()) ? response.getOpenId() : response.getUserId(); + data.put("openId", openid); + + return Result.success(CodeEnum.SUCCESS, data); } return Result.fail(CodeEnum.FAIL); } - - private AlipayConfig getAlipayConfig() { + private AlipayConfig getAlipayConfig() { AlipayConfig alipayConfig = new AlipayConfig(); alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); alipayConfig.setAppId(aliAppId); @@ -421,16 +399,12 @@ public class PayController { } - public static void main(String[] args){ - LocalDate date=LocalDate.now(); - if(date.isLeapYear()){ + public static void main(String[] args) { + LocalDate date = LocalDate.now(); + if (date.isLeapYear()) { System.out.println(); } } - - - - } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/model/PaymentReq.java b/src/main/java/com/chaozhanggui/system/cashierservice/model/PaymentReq.java index dc8b2df..f8efb59 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/model/PaymentReq.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/model/PaymentReq.java @@ -27,7 +27,4 @@ public class PaymentReq implements Serializable { private String userId; private String shopId; - - - } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index 2f346b9..d54d06c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -1854,7 +1854,7 @@ public class PayService { return "QR" + date + randomNum; } - public Result createOrder(String ip, String userId, String payType, String shopId, BigDecimal amount) throws JsonProcessingException { + public Result createOrder(String ip, String userId, String payType, String shopId, String orderId, BigDecimal amount) throws JsonProcessingException { if (ObjectUtil.isNull(userId) || ObjectUtil.isEmpty(userId) || ObjectUtil.isEmpty(payType) || ObjectUtil.isNull(payType) || ObjectUtil.isNull(shopId) || ObjectUtil.isEmpty(shopId) || @@ -1868,31 +1868,36 @@ public class PayService { return Result.fail(CodeEnum.SHOPINFONOEXIST); } + TbOrderInfo orderInfo; - TbOrderInfo orderInfo = new TbOrderInfo(); + if (StrUtil.isNotBlank(orderId)) { + orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId)); + } else { + orderInfo = new TbOrderInfo(); - String orderNo = generateOrderNumber(); - orderInfo.setOrderNo(orderNo); - orderInfo.setSettlementAmount(amount); - orderInfo.setPackFee(BigDecimal.ZERO); - orderInfo.setOriginAmount(amount); - orderInfo.setPayAmount(amount); - orderInfo.setAmount(amount); - orderInfo.setRefundAmount(BigDecimal.ZERO); - orderInfo.setPayType(payType); - orderInfo.setPayAmount(amount); - orderInfo.setOrderAmount(amount); - orderInfo.setSendType("QR"); - orderInfo.setStatus("WAIT_PAY"); - orderInfo.setMerchantId(shopInfo.getMerchantId()); - orderInfo.setShopId(shopId); - orderInfo.setRefundAble(Byte.valueOf("1")); - orderInfo.setSystemTime(System.currentTimeMillis()); - orderInfo.setCreatedAt(System.currentTimeMillis()); - orderInfo.setIsAccepted(Byte.valueOf("1")); - orderInfo.setTradeDay(DateUtils.getDay()); + String orderNo = generateOrderNumber(); + orderInfo.setOrderNo(orderNo); + orderInfo.setSettlementAmount(amount); + orderInfo.setPackFee(BigDecimal.ZERO); + orderInfo.setOriginAmount(amount); + orderInfo.setPayAmount(amount); + orderInfo.setAmount(amount); + orderInfo.setRefundAmount(BigDecimal.ZERO); + orderInfo.setPayType(payType); + orderInfo.setPayAmount(amount); + orderInfo.setOrderAmount(amount); + orderInfo.setSendType("QR"); + orderInfo.setStatus("WAIT_PAY"); + orderInfo.setMerchantId(shopInfo.getMerchantId()); + orderInfo.setShopId(shopId); + orderInfo.setRefundAble(Byte.valueOf("1")); + orderInfo.setSystemTime(System.currentTimeMillis()); + orderInfo.setCreatedAt(System.currentTimeMillis()); + orderInfo.setIsAccepted(Byte.valueOf("1")); + orderInfo.setTradeDay(DateUtils.getDay()); - tbOrderInfoMapper.insert(orderInfo); + tbOrderInfoMapper.insert(orderInfo); + } TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderInfo.getId().toString()); From 1ad6aa3de7cf95d79a3208a4e2624b5fe5702420 Mon Sep 17 00:00:00 2001 From: yijiegong Date: Thu, 19 Sep 2024 13:44:56 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=94=AF=E4=BB=98=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0remark=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/controller/PayController.java | 2 +- .../system/cashierservice/model/PaymentReq.java | 2 ++ .../system/cashierservice/service/PayService.java | 12 ++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java index 2d24a3d..b5e7178 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java @@ -293,7 +293,7 @@ public class PayController { public Result createOrder(HttpServletRequest request, @RequestBody PaymentReq paymentReq) { try { return payService.createOrder(IpUtil.getIpAddr(request), paymentReq.getUserId(), paymentReq.getPayType(), - paymentReq.getShopId(), paymentReq.getOrderId(), paymentReq.getPayAmount()); + paymentReq.getShopId(), paymentReq.getOrderId(), paymentReq.getPayAmount(), paymentReq.getRemark()); } catch (JsonProcessingException e) { e.printStackTrace(); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/model/PaymentReq.java b/src/main/java/com/chaozhanggui/system/cashierservice/model/PaymentReq.java index f8efb59..221f695 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/model/PaymentReq.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/model/PaymentReq.java @@ -27,4 +27,6 @@ public class PaymentReq implements Serializable { private String userId; private String shopId; + + private String remark; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index d54d06c..30ce8d6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -1854,7 +1854,8 @@ public class PayService { return "QR" + date + randomNum; } - public Result createOrder(String ip, String userId, String payType, String shopId, String orderId, BigDecimal amount) throws JsonProcessingException { + public Result createOrder(String ip, String userId, String payType, String shopId, String orderId, + BigDecimal amount, String remark) throws JsonProcessingException { if (ObjectUtil.isNull(userId) || ObjectUtil.isEmpty(userId) || ObjectUtil.isEmpty(payType) || ObjectUtil.isNull(payType) || ObjectUtil.isNull(shopId) || ObjectUtil.isEmpty(shopId) || @@ -1872,6 +1873,13 @@ public class PayService { if (StrUtil.isNotBlank(orderId)) { orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId)); + if (ObjectUtil.isNull(orderInfo)) { + return Result.fail(CodeEnum.ORDERNOEXIST); + } + if (StrUtil.isNotBlank(remark)) { + orderInfo.setRemark(remark); + tbOrderInfoMapper.updateByPrimaryKey(orderInfo); + } } else { orderInfo = new TbOrderInfo(); @@ -1895,11 +1903,11 @@ public class PayService { orderInfo.setCreatedAt(System.currentTimeMillis()); orderInfo.setIsAccepted(Byte.valueOf("1")); orderInfo.setTradeDay(DateUtils.getDay()); + orderInfo.setRemark(remark); tbOrderInfoMapper.insert(orderInfo); } - TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderInfo.getId().toString()); if (ObjectUtil.isEmpty(payment) || payment == null) { payment = new TbOrderPayment();