From 7cabb2a109c1489bd2a3963c2e76a30018390462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E9=B9=8F=E8=BE=89?= <18322780655@163.com> Date: Mon, 20 May 2024 15:57:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=89=88=E5=BC=80?= =?UTF-8?q?=E6=94=BE=E5=B9=B3=E5=8F=B0=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/dao/TbActivateMapper.java | 26 ++++ .../cashierservice/entity/TbActivate.java | 78 +++++++++++ .../cashierservice/service/PayService.java | 103 ++++++++++++++- .../service/ProductService.java | 3 +- .../thirdpay/service/ThirdPayService.java | 2 +- src/main/resources/application.yml | 2 +- .../generator-mapper/generatorConfig.xml | 8 +- .../resources/mapper/TbActivateMapper.xml | 121 ++++++++++++++++++ 8 files changed, 334 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java create mode 100644 src/main/resources/mapper/TbActivateMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java new file mode 100644 index 0000000..2b8505e --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java @@ -0,0 +1,26 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbActivate; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; + +@Component +@Mapper +public interface TbActivateMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TbActivate record); + + int insertSelective(TbActivate record); + + TbActivate selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TbActivate record); + + int updateByPrimaryKey(TbActivate record); + + TbActivate selectByAmount(@Param("shopId") String shopId,@Param("amount") BigDecimal amount); +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java new file mode 100644 index 0000000..c223bfc --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java @@ -0,0 +1,78 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.io.Serializable; +import java.math.BigDecimal; + +public class TbActivate implements Serializable { + private Integer id; + + private Integer shopId; + + private Integer minNum; + + private Integer maxNum; + + private BigDecimal handselNum; + + private String handselType; + + private String isDel; + + private static final long serialVersionUID = 1L; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getMinNum() { + return minNum; + } + + public void setMinNum(Integer minNum) { + this.minNum = minNum; + } + + public Integer getMaxNum() { + return maxNum; + } + + public void setMaxNum(Integer maxNum) { + this.maxNum = maxNum; + } + + public BigDecimal getHandselNum() { + return handselNum; + } + + public void setHandselNum(BigDecimal handselNum) { + this.handselNum = handselNum; + } + + public String getHandselType() { + return handselType; + } + + public void setHandselType(String handselType) { + this.handselType = handselType == null ? null : handselType.trim(); + } + + public String getIsDel() { + return isDel; + } + + public void setIsDel(String isDel) { + this.isDel = isDel == null ? null : isDel.trim(); + } +} \ No newline at end of file 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 6263cf1..653ddc4 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -120,6 +120,8 @@ public class PayService { @Autowired ThirdPayService thirdPayService; + + @Resource private TbGroupOrderInfoMapper tbGroupOrderInfoMapper; @Autowired @@ -127,6 +129,9 @@ public class PayService { @Resource private GroupOrderCouponService orderCouponService; + @Autowired + TbActivateMapper tbActivateMapper; + @Transactional(rollbackFor = Exception.class) public Result payOrder(String openId,String orderId,String ip) throws Exception { @@ -630,8 +635,9 @@ public class PayService { return Result.fail("对应的用户信息不存在"); } - if(ObjectUtil.isEmpty(tbShopUser.getIsVip())||!"1".equals(tbShopUser.getIsVip().toString())){ - return Result.fail("非会员用户不允许充值"); + + if("0".equals(tbShopUser.getIsPwd())){ + return Result.fail("用户支付密码未设置"); } @@ -848,10 +854,103 @@ public class PayService { flow.setBalance(tbShopUser.getAmount()); flow.setCreateTime(new Date()); tbShopUserFlowMapper.insert(flow); + TbActivate activate= tbActivateMapper.selectByAmount(tbShopUser.getShopId(),memberIn.getAmount()); + if(ObjectUtil.isNotEmpty(activate)&&ObjectUtil.isNotNull(activate)){ + BigDecimal amount=BigDecimal.ZERO; + switch (activate.getHandselType()){ + case "GD": + amount=activate.getHandselNum(); + break; + case "RATIO": + amount=memberIn.getAmount().multiply(activate.getHandselNum()); + break; + } + + + tbShopUser.setAmount(tbShopUser.getAmount().add(amount)); + tbShopUser.setUpdatedAt(System.currentTimeMillis()); + tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser); + + flow=new TbShopUserFlow(); + flow.setShopUserId(Integer.valueOf(tbShopUser.getId())); + flow.setBizCode("scanMemberAwardIn"); + flow.setBizName("会员充值奖励"); + flow.setAmount(amount); + flow.setBalance(tbShopUser.getAmount()); + flow.setCreateTime(new Date()); + tbShopUserFlowMapper.insert(flow); + + } return "success"; } + + public String fstMemberInSuccess(String payOrderNO,String tradeNo){ + TbMemberIn memberIn= tbMemberInMapper.selectByOrderNo(payOrderNO); + if(ObjectUtil.isEmpty(memberIn)){ + return "充值记录不存在"; + } + + memberIn.setTradeNo(tradeNo); + memberIn.setStatus("0"); + memberIn.setUpdateTime(new Date()); + tbMemberInMapper.updateByPrimaryKeySelective(memberIn); + + TbShopUser tbShopUser= tbShopUserMapper.selectByUserIdAndShopId(memberIn.getUserId().toString(),memberIn.getShopId().toString()); + if(ObjectUtil.isEmpty(tbShopUser)){ + return "用户信息不存在"; + } + + if(!"1".equals(tbShopUser.getIsVip().toString())){ + tbShopUser.setIsVip(Byte.parseByte("1")); + } + + //修改客户资金 + tbShopUser.setAmount(tbShopUser.getAmount().add(memberIn.getAmount())); + tbShopUser.setUpdatedAt(System.currentTimeMillis()); + tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser); + + TbShopUserFlow flow=new TbShopUserFlow(); + flow.setShopUserId(Integer.valueOf(tbShopUser.getId())); + flow.setBizCode("scanMemberIn"); + flow.setBizName("会员扫码充值"); + flow.setAmount(memberIn.getAmount()); + flow.setBalance(tbShopUser.getAmount()); + flow.setCreateTime(new Date()); + tbShopUserFlowMapper.insert(flow); + + TbActivate activate= tbActivateMapper.selectByAmount(tbShopUser.getShopId(),memberIn.getAmount()); + if(ObjectUtil.isNotEmpty(activate)&&ObjectUtil.isNotNull(activate)){ + BigDecimal amount=BigDecimal.ZERO; + switch (activate.getHandselType()){ + case "GD": + amount=activate.getHandselNum(); + break; + case "RATIO": + amount=memberIn.getAmount().multiply(activate.getHandselNum()); + break; + } + + + tbShopUser.setAmount(tbShopUser.getAmount().add(amount)); + tbShopUser.setUpdatedAt(System.currentTimeMillis()); + tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser); + + flow=new TbShopUserFlow(); + flow.setShopUserId(Integer.valueOf(tbShopUser.getId())); + flow.setBizCode("scanMemberAwardIn"); + flow.setBizName("会员充值奖励"); + flow.setAmount(amount); + flow.setBalance(tbShopUser.getAmount()); + flow.setCreateTime(new Date()); + tbShopUserFlowMapper.insert(flow); + + } + return "SUCCESS"; + } + + // public Result returnOrder(){ // // } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 55f09fe..54cbf19 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -83,7 +83,8 @@ public class ProductService { tbShopUser.setShopId(shopId); tbShopUser.setUserId(userId); tbShopUser.setMiniOpenId(openId); - tbShopUser.setIsPwd("1"); + tbShopUser.setPwd(MD5Util.encrypt("123456")); + tbShopUser.setIsPwd("0"); tbShopUser.setCreatedAt(System.currentTimeMillis()); tbShopUser.setUpdatedAt(System.currentTimeMillis()); tbShopUserMapper.insert(tbShopUser); 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 2c0f05b..65b0d48 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 @@ -295,6 +295,6 @@ public class ThirdPayService { public static void main(String[] args) { -// mainScan("https://paymentapi.sxczgkj.cn","6639fdc9fdf6f35856a23b3c", "测试支付", "测试支付", 1L, "wx212769170d2c6b2a", "131112206836873461", "CZ".concat(String.valueOf(System.currentTimeMillis())), "S2405103298", "https://", "fEu7tJgqaoPCA5QevafnSHfqHtO7rWcvhyfA0ltuab7rbpgOlab7CFCmqxMIbssUvbOnFKLdQqW5xUvhzb7FoxJNMAkIf2KDzlgDl6Diw1oBq56agSAFHhgYr3bLxXXI"); + new ThirdPayService().mainScan("https://paymentapi.sxczgkj.cn","6639fdc9fdf6f35856a23b3c", "测试支付", "测试支付", 1L, "wx212769170d2c6b2a", "132933158610062686", "CZ".concat(String.valueOf(System.currentTimeMillis())), "S2405103298", "https://cashierclient.sxczgkj.cn/cashierService/notify/fstmemberInCallBack", "fEu7tJgqaoPCA5QevafnSHfqHtO7rWcvhyfA0ltuab7rbpgOlab7CFCmqxMIbssUvbOnFKLdQqW5xUvhzb7FoxJNMAkIf2KDzlgDl6Diw1oBq56agSAFHhgYr3bLxXXI"); } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8a8c34d..5ebc9df 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -57,5 +57,5 @@ aliyun: thirdPay: payType: fushangtong - callBack: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay + callBack: https://cashierclient.sxczgkj.cn/${server.servlet.context-path}/notify/fstmemberInCallBack url: https://paymentapi.sxczgkj.cn diff --git a/src/main/resources/generator-mapper/generatorConfig.xml b/src/main/resources/generator-mapper/generatorConfig.xml index c908550..87787f8 100644 --- a/src/main/resources/generator-mapper/generatorConfig.xml +++ b/src/main/resources/generator-mapper/generatorConfig.xml @@ -6,7 +6,7 @@ - + @@ -19,8 +19,8 @@ - + @@ -52,7 +52,7 @@ -
diff --git a/src/main/resources/mapper/TbActivateMapper.xml b/src/main/resources/mapper/TbActivateMapper.xml new file mode 100644 index 0000000..0f29dcc --- /dev/null +++ b/src/main/resources/mapper/TbActivateMapper.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + id, shop_id, min_num, max_num, handsel_num, handsel_type, is_del + + + + delete from tb_activate + where id = #{id,jdbcType=INTEGER} + + + insert into tb_activate (id, shop_id, min_num, + max_num, handsel_num, handsel_type, + is_del) + values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{minNum,jdbcType=INTEGER}, + #{maxNum,jdbcType=INTEGER}, #{handselNum,jdbcType=DECIMAL}, #{handselType,jdbcType=VARCHAR}, + #{isDel,jdbcType=VARCHAR}) + + + insert into tb_activate + + + id, + + + shop_id, + + + min_num, + + + max_num, + + + handsel_num, + + + handsel_type, + + + is_del, + + + + + #{id,jdbcType=INTEGER}, + + + #{shopId,jdbcType=INTEGER}, + + + #{minNum,jdbcType=INTEGER}, + + + #{maxNum,jdbcType=INTEGER}, + + + #{handselNum,jdbcType=DECIMAL}, + + + #{handselType,jdbcType=VARCHAR}, + + + #{isDel,jdbcType=VARCHAR}, + + + + + update tb_activate + + + shop_id = #{shopId,jdbcType=INTEGER}, + + + min_num = #{minNum,jdbcType=INTEGER}, + + + max_num = #{maxNum,jdbcType=INTEGER}, + + + handsel_num = #{handselNum,jdbcType=DECIMAL}, + + + handsel_type = #{handselType,jdbcType=VARCHAR}, + + + is_del = #{isDel,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update tb_activate + set shop_id = #{shopId,jdbcType=INTEGER}, + min_num = #{minNum,jdbcType=INTEGER}, + max_num = #{maxNum,jdbcType=INTEGER}, + handsel_num = #{handselNum,jdbcType=DECIMAL}, + handsel_type = #{handselType,jdbcType=VARCHAR}, + is_del = #{isDel,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + + + + \ No newline at end of file