From 29293fd093662758a42ed08c5dfd6bf81b0e71e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E9=B9=8F=E8=BE=89?= <18322780655@163.com> Date: Thu, 30 May 2024 09:17:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=A4=E7=8F=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CloudPrinterService.java | 23 ++++---- .../cashierservice/service/DutyService.java | 53 +++++++++++++++---- 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java index 760655d..9a56d34 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java @@ -616,12 +616,17 @@ public class CloudPrinterService { list= JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(mapList), HandoverInfo.PayInfo.class); } - ShopUserDutyPay shopUserDutyPay=shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(),"deposit"); - if(ObjectUtil.isNotEmpty(shopUserDutyPay)){ - memberData=new ArrayList<>(); - memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(),"储值卡充值")); - memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberOutAmount().toPlainString(),"储值卡支付")); - } +// ShopUserDutyPay shopUserDutyPay=shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(),"deposit"); +// if(ObjectUtil.isNotEmpty(shopUserDutyPay)){ +// memberData=new ArrayList<>(); +// memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(),"储值卡充值")); +// memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberOutAmount().toPlainString(),"储值卡支付")); +// } + + + memberData=new ArrayList<>(); + memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(),"储值卡充值")); + memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberOutAmount().toPlainString(),"储值卡支付")); List> categries= shopUserDutyPayMapper.selectCetoryBydutyId(shopUserDuty.getId()); @@ -634,13 +639,13 @@ public class CloudPrinterService { ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())?DateUtils.getTime(shopUserDuty.getLoginTime()):null, ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime())?DateUtils.getTime(shopUserDuty.getLoginOutTime()):"", ObjectUtil.isNull(shopStaff.getName())?"":shopStaff.getName(), - list,memberData,shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).add(ObjectUtil.isNull(shopUserDuty.getIncomeAmount())?BigDecimal.ZERO:shopUserDuty.getIncomeAmount()).toPlainString(), + list,memberData,shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).toPlainString(), "0", shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(), - shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).add(ObjectUtil.isNull(shopUserDuty.getIncomeAmount())?BigDecimal.ZERO:shopUserDuty.getIncomeAmount()).subtract(shopUserDuty.getReturnAmount()).toPlainString(), + shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).toPlainString(), shopUserDuty.getReturnAmount().toPlainString(), shopUserDuty.getOrderNum().toString(), - productCategories,shopUserDuty.getQuickAmount().toPlainString() + productCategories,ObjectUtil.isNull(shopUserDuty.getQuickAmount())?"0":shopUserDuty.getQuickAmount().toPlainString() ); String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java index 6aa8e36..4bacf73 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java @@ -107,7 +107,34 @@ public class DutyService { } - }else { + }else if("wxMemberIn".equals(type)){ + String shopId=jsonObject.getString("shopId"); + + BigDecimal amount=new BigDecimal(jsonObject.getString("amount")); + + ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndStatus(Integer.valueOf(shopId), "0"); + TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId)); + + if(Objects.isNull(shopUserDuty)){ + shopUserDuty = new ShopUserDuty(Integer.valueOf(shopId), tbToken.getCreateTime(), 1, BigDecimal.ZERO, shopInfo.getShopName(), "0", + BigDecimal.ZERO, Integer.valueOf(shopId), BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, ""); + + shopUserDuty.setTokenId(0); + shopUserDuty.setType("wxIn"); + if (Objects.nonNull(shopInfo)) { + shopUserDuty.setUserName(shopInfo.getShopName()); + } + shopUserDuty.setTradeDay(DateUtils.getDay()); + shopUserDuty.setReturnAmount(BigDecimal.ZERO); + shopUserDuty.setMemberInAmount(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())?amount:shopUserDuty.getMemberInAmount().add(amount)); + shopUserDutyMapper.insert(shopUserDuty); + + }else { + shopUserDuty.setMemberInAmount(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())?amount:shopUserDuty.getMemberInAmount().add(amount)); + shopUserDutyMapper.updateByPrimaryKey(shopUserDuty); + } + + } else { if (type.equals("return") || type.equals("create")) { if (Objects.isNull(tbToken)) { throw new MsgException("当前用户不存在"); @@ -314,17 +341,21 @@ public class DutyService { shopUserDutyDetailMapper.batchInsert(detaiList); } } - ShopUserDutyPay shopUserDutyPay = shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(), orderInfo.getPayType()); - if (Objects.nonNull(shopUserDutyPay)) { - shopUserDutyPay.setAmount(orderInfo.getOrderAmount().add(shopUserDutyPay.getAmount())); - shopUserDutyPayMapper.updateByPrimaryKeySelective(shopUserDutyPay); - } else { - shopUserDutyPay = new ShopUserDutyPay(); - shopUserDutyPay.setDutyId(shopUserDuty.getId()); - shopUserDutyPay.setType(orderInfo.getPayType()); - shopUserDutyPay.setAmount(orderInfo.getOrderAmount()); - shopUserDutyPayMapper.insert(shopUserDutyPay); + + if(!orderInfo.getOrderType().equals("deposit")){ + ShopUserDutyPay shopUserDutyPay = shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(), orderInfo.getPayType()); + if (Objects.nonNull(shopUserDutyPay)) { + shopUserDutyPay.setAmount(orderInfo.getOrderAmount().add(shopUserDutyPay.getAmount())); + shopUserDutyPayMapper.updateByPrimaryKeySelective(shopUserDutyPay); + } else { + shopUserDutyPay = new ShopUserDutyPay(); + shopUserDutyPay.setDutyId(shopUserDuty.getId()); + shopUserDutyPay.setType(orderInfo.getPayType()); + shopUserDutyPay.setAmount(orderInfo.getOrderAmount()); + shopUserDutyPayMapper.insert(shopUserDutyPay); + } } + } else { if (type.equals("close")) { JSONObject tokenJson = TokenUtil.parseParamFromToken(tbToken.getToken());