diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java index 216dbcd..1b4cb4d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java @@ -108,6 +108,7 @@ public class OrderController { @RequestParam(value = "size", required = false, defaultValue = "1") Integer size){ return orderService.findOrder(shopId,status,page,size,orderNo); } + @GetMapping("/orderDetail") public Result orderDetail(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, @RequestHeader("clientType") String clientType, @RequestParam("shopId") Integer shopId, diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyMapper.java index 7146a3e..08cc61f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/ShopUserDutyMapper.java @@ -32,4 +32,8 @@ public interface ShopUserDutyMapper { BigDecimal selectSumAmount(@Param("shopId") String shopId); ShopUserDuty selectByTokenIdAndTradeDay(@Param("tokenId") int tokenId, @Param("day") String day,@Param("shopId") String shopId); + + ShopUserDuty selectByShopIdAndTrade(@Param("shopId") Integer shopId,@Param("day") String day); + +// List selectByShopIdAndTradeAll(@Param("shopId") Integer shopId,@Param("day") String day,@Param("tokenId") Integer tokenId); } \ No newline at end of file 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 480fb28..35d3cf3 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java @@ -50,6 +50,7 @@ public class DutyService { String token = jsonObject.getString("token"); String type = jsonObject.getString("type"); TbToken tbToken = tbTokenMapper.selectByToken(token); + String day = DateUtils.getDay(); if (type.equals("return") || type.equals("create")) { if (Objects.isNull(tbToken)) { throw new MsgException("当前用户不存在"); @@ -65,7 +66,9 @@ public class DutyService { throw new MsgException("订单不存在"); } List list = orderDetailMapper.selectAllByOrderId(orderId); - ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenId(tokenId); +// ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenId(tokenId); + ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndTrade(shopId,day); +// ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenIdAndTradeDay(tokenId, day, orderInfo.getShopId()); BigDecimal cashAmount = BigDecimal.ZERO; if (orderInfo.getPayType().equals("cash")) { cashAmount = orderInfo.getPayAmount(); @@ -165,7 +168,6 @@ public class DutyService { } } } else if (type.equals("wxcreate")) { - String day = DateUtils.getDay(); Integer orderId = jsonObject.getInteger("orderId"); TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId); if (Objects.isNull(orderInfo)) { @@ -176,7 +178,8 @@ public class DutyService { if (orderInfo.getPayType().equals("cash")) { cashAmount = orderInfo.getPayAmount(); } - ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenIdAndTradeDay(0, day, orderInfo.getShopId()); + ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndTrade(Integer.valueOf(orderInfo.getShopId()), day); +// ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenIdAndTradeDay(0, day, orderInfo.getShopId()); TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId())); if (Objects.isNull(shopUserDuty)) { shopUserDuty = new ShopUserDuty(Integer.valueOf(orderInfo.getShopId()), new Date(), 1, orderInfo.getOrderAmount(), "", "0", diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ShopInfoService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ShopInfoService.java index b92ecd8..a66e65b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ShopInfoService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ShopInfoService.java @@ -6,6 +6,7 @@ import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; +import com.chaozhanggui.system.cashierservice.util.DateUtils; import com.chaozhanggui.system.cashierservice.util.TokenUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -55,7 +56,12 @@ public class ShopInfoService { if (Objects.isNull(tbToken)){ return Result.fail(CodeEnum.PARAM); } - ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenId(tbToken.getId()); + JSONObject jsonObject = TokenUtil.parseParamFromToken(token); + Integer shopId = jsonObject.getInteger("shopId"); + String day = DateUtils.getDay(); +// ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenId(tbToken.getId()); + ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndTrade(shopId,day); +// List list = shopUserDutyMapper.selectByShopIdAndTradeAll(shopId,day,tbToken.getId()); if (Objects.nonNull(shopUserDuty)){ // PageHelper.startPage(page, pageSize); List shopTables=shopUserDutyDetailMapper.selectAllByDuctId(shopUserDuty.getId()); diff --git a/src/main/resources/mapper/ShopUserDutyMapper.xml b/src/main/resources/mapper/ShopUserDutyMapper.xml index 1b51f23..6167996 100644 --- a/src/main/resources/mapper/ShopUserDutyMapper.xml +++ b/src/main/resources/mapper/ShopUserDutyMapper.xml @@ -44,6 +44,10 @@ resultType="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty"> select * from tb_shop_user_duty where shop_id = #{shopId} and trade_day = #{day} and token_id = #{tokenId}; + delete from tb_shop_user_duty where id = #{id,jdbcType=INTEGER}