Sfoglia il codice sorgente

Merge branch 'master' of http://git.zonelife.cn:3000/fubojin/smqjh

zhangxin 4 settimane fa
parent
commit
f146bd198b

+ 1 - 10
yami-shop-api/src/main/java/com/yami/shop/api/controller/MyOrderController.java

@@ -123,11 +123,9 @@ public class MyOrderController {
     @ApiImplicitParam(name = "orderNumber", value = "订单号", required = true, dataType = "String")
     public ResponseEntity<OrderShopDto> orderDetail(@RequestParam(value = "orderNumber", required = true) String orderNumber) {
         String userId = SecurityUtils.getUser().getUserId();
-//        String userId = "36726893042d492aba446439c5f00584";
         OrderShopDto orderShopDto = new OrderShopDto();
 
         Order order = orderService.getOrderByOrderNumberAndUserId(orderNumber, userId, true);
-//        Order order = orderService.getOne(Wrappers.<Order>lambdaQuery().eq(Order::getOrderNumber, orderNumber));
         SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日$HH:mm");
         if (null != order.getPayTime()) {
             // 转换为 LocalDateTime 并增加 1 小时
@@ -158,18 +156,10 @@ public class MyOrderController {
 
         //计算订单使用积分
         Integer score = 0;
-//        for (OrderItem orderItem : orderItems) {
-//            score += orderItem.getUseScore();
-//        }
-//        if (score > 0) {
-//            score = (int) (score + order.getFreightAmount());
-//        }
-
         List<OrderItemDto> orderItemDtoList = mapperFacade.mapAsList(orderItems, OrderItemDto.class);
         //加上运费
         orderShopDto.setOrderScore(score);
         orderShopDto.setShopId(shopDetail.getShopId());
-//        orderShopDto.setShopId(0L);
         orderShopDto.setDvyType(order.getDvyType());
         orderShopDto.setShopName(shopDetail.getShopName());
         orderShopDto.setActualTotal(order.getActualTotal());
@@ -198,6 +188,7 @@ public class MyOrderController {
         orderShopDto.setFianllyTime(order.getFinallyTime());
         // 取消时间
         orderShopDto.setCancelTime(order.getCancelTime());
+        orderShopDto.setCancelReason(order.getCancelReason());
         // 更新时间
         orderShopDto.setUpdateTime(order.getUpdateTime());
 

+ 19 - 44
yami-shop-api/src/main/java/com/yami/shop/api/controller/OrderRefundController.java

@@ -220,9 +220,9 @@ public class OrderRefundController {
         newOrderRefund.setBuyerMobile(orderRefundParam.getBuyerMobile());
         newOrderRefund.setPhotoFiles(orderRefundParam.getPhotoFiles());
         newOrderRefund.setReturnMoneySts(ReturnMoneyStsType.APPLY.value());
+        newOrderRefund.setFreightAmount(orderRefundParam.getFreightAmount());
         newOrderRefund.setApplyTime(new Date());
         newOrderRefund.setUpdateTime(new Date());
-        newOrderRefund.setFreightAmount(orderRefundParam.getFreightAmount());
 
         long orderPoints = order.getOffsetPoints() == null ? 0 : order.getOffsetPoints();
         if (orderPoints == 0) {
@@ -244,25 +244,10 @@ public class OrderRefundController {
         }
 
         //生成退款记录
-        //生成申请退款记录
-        OrderRefundRecord orderRefundRecord = new OrderRefundRecord();
-        orderRefundRecord.setOrderRefundId(orderRefund.getRefundId());
-        orderRefundRecord.setInstructions(newOrderRefund.getBuyerReason());
-        orderRefundRecord.setCreateTime(new Date());
-        orderRefundRecord.setUpdateTime(new Date());
-        orderRefundRecord.setAuditStatus(1);
-        orderRefundRecord.setSort(1);
-        orderRefundRecordMapper.insert(orderRefundRecord);
+        addOrderRefundRecord(orderRefund.getRefundId(), 1, 1, newOrderRefund.getBuyerReason());
 
         //生成待商家审核记录
-        OrderRefundRecord orderRefundRecord1 = new OrderRefundRecord();
-        orderRefundRecord1.setOrderRefundId(orderRefund.getRefundId());
-        orderRefundRecord1.setInstructions("你的服务单已申请成功,待商家审核");
-        orderRefundRecord1.setCreateTime(new Date());
-        orderRefundRecord1.setUpdateTime(new Date());
-        orderRefundRecord1.setAuditStatus(2);
-        orderRefundRecord1.setSort(2);
-        orderRefundRecordMapper.insert(orderRefundRecord1);
+        addOrderRefundRecord(orderRefund.getRefundId(), 2, 2, "你的服务单已申请成功,待商家审核");
 
         orderRefundService.removeById(refundId);
         orderRefundSkuMapper.delete(new LambdaQueryWrapper<OrderRefundSku>().eq(OrderRefundSku::getOrderRefundId, refundId));
@@ -420,25 +405,10 @@ public class OrderRefundController {
         }
 
         //生成退款记录
-        //生成申请退款记录
-        OrderRefundRecord orderRefundRecord = new OrderRefundRecord();
-        orderRefundRecord.setOrderRefundId(orderRefund.getRefundId());
-        orderRefundRecord.setInstructions(newOrderRefund.getBuyerReason());
-        orderRefundRecord.setCreateTime(new Date());
-        orderRefundRecord.setUpdateTime(new Date());
-        orderRefundRecord.setAuditStatus(1);
-        orderRefundRecord.setSort(1);
-        orderRefundRecordMapper.insert(orderRefundRecord);
+        addOrderRefundRecord(orderRefund.getRefundId(), 1, 1, newOrderRefund.getBuyerReason());
 
         //生成待商家审核记录
-        OrderRefundRecord orderRefundRecord1 = new OrderRefundRecord();
-        orderRefundRecord1.setOrderRefundId(orderRefund.getRefundId());
-        orderRefundRecord1.setInstructions("你的服务单已申请成功,待商家审核");
-        orderRefundRecord1.setCreateTime(new Date());
-        orderRefundRecord1.setUpdateTime(new Date());
-        orderRefundRecord1.setAuditStatus(2);
-        orderRefundRecord1.setSort(2);
-        orderRefundRecordMapper.insert(orderRefundRecord1);
+        addOrderRefundRecord(orderRefund.getRefundId(), 2, 2, "你的服务单已申请成功,待商家审核");
 
         //创建海博退款单
         log.info("创建海博退款单,生成海博退款单信息{}", orderRefund);
@@ -687,15 +657,8 @@ public class OrderRefundController {
         }
         orderRefundService.changeStatus(refundSn, 40);
 
-        OrderRefundRecord orderRefundRecord = new OrderRefundRecord();
-        orderRefundRecord.setOrderRefundId(orderRefund.getRefundId());
-        orderRefundRecord.setInstructions("用户主动撤回申请,退货退款关闭。");
-        Date date = new Date();
-        orderRefundRecord.setCreateTime(date);
-        orderRefundRecord.setUpdateTime(date);
-        orderRefundRecord.setAuditStatus(4);
-        orderRefundRecord.setSort(4);
-        orderRefundRecordMapper.insert(orderRefundRecord);
+        addOrderRefundRecord(orderRefund.getRefundId(), 4, 4, "用户主动撤回申请,退货退款关闭。");
+
         return ResponseEntity.ok("撤销成功");
     }
 
@@ -894,4 +857,16 @@ public class OrderRefundController {
             }
         }
     }
+
+    private void addOrderRefundRecord(Long refundId, Integer auditStatus, Integer sort, String instructions) {
+        OrderRefundRecord orderRefundRecord = new OrderRefundRecord();
+        orderRefundRecord.setOrderRefundId(refundId);
+        orderRefundRecord.setInstructions(instructions);
+        Date date = new Date();
+        orderRefundRecord.setCreateTime(date);
+        orderRefundRecord.setUpdateTime(date);
+        orderRefundRecord.setAuditStatus(auditStatus);
+        orderRefundRecord.setSort(sort);
+        orderRefundRecordMapper.insert(orderRefundRecord);
+    }
 }

+ 15 - 1
yami-shop-api/src/main/java/com/yami/shop/api/controller/RefundDeliveryController.java

@@ -3,6 +3,7 @@ package com.yami.shop.api.controller;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yami.shop.bean.enums.ReturnMoneyStsType;
 import com.yami.shop.bean.model.*;
 import com.yami.shop.common.exception.GlobalException;
 import com.yami.shop.common.util.PageParam;
@@ -15,6 +16,7 @@ import com.yami.shop.service.RefundDeliveryService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.ResponseEntity;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -28,6 +30,7 @@ import java.util.Date;
 @RestController
 @RequestMapping("/refund/delivery")
 @Api(tags = "退货物流信息接口")
+@Slf4j
 @AllArgsConstructor
 public class RefundDeliveryController {
 
@@ -76,7 +79,7 @@ public class RefundDeliveryController {
     @PostMapping("/save")
     @ApiOperation("保存退货物流信息")
     @Transactional(rollbackFor = Exception.class)
-    public R<?> save(@Valid @RequestBody RefundDelivery refundDelivery) {
+    public synchronized R<?> save(@Valid @RequestBody RefundDelivery refundDelivery) {
 
 
         //获取门店信息
@@ -99,6 +102,13 @@ public class RefundDeliveryController {
             throw new GlobalException("该退款单不存在");
         }
 
+        if (orderRefund.getReturnMoneySts() != 60) {
+            throw new GlobalException("该退款单状态不对不能提交");
+        }
+
+        orderRefund.setReturnMoneySts(ReturnMoneyStsType.RECEIVE.value());
+        orderRefund.setShipTime(new Date());
+        orderRefund.setUpdateTime(new Date());
         orderRefund.setIsReturnLogistics(true);
         orderRefundService.updateById(orderRefund);
 
@@ -111,6 +121,10 @@ public class RefundDeliveryController {
         orderRefundRecord.setAuditStatus(7);
         orderRefundRecord.setSort(5);
         orderRefundRecordMapper.insert(orderRefundRecord);
+
+        log.info("客户填写完成快递信息后海博退款单状态同步65");
+        orderRefundService.changeStatus(orderRefund.getRefundSn(), ReturnMoneyStsType.RECEIVE.value());
+
         return R.SUCCESS("添加成功");
     }
 

+ 3 - 3
yami-shop-api/src/main/resources/redisson/redisson-dev.yml

@@ -1,8 +1,8 @@
 # 单节点设置
 singleServerConfig:
-  address: redis://192.168.1.242:6379
-  database: 1
-  password: FaajjVy8rl(k
+  address: redis://47.109.23.229:6379
+  database: 5
+  password: zswladmin
   idleConnectionTimeout: 10000
   pingTimeout: 1000
   connectTimeout: 10000

+ 5 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/app/dto/OrderShopDto.java

@@ -74,6 +74,7 @@ public class OrderShopDto implements Serializable {
     @ApiModelProperty(value = "优惠券优惠金额", required = true)
     private Double couponMoney;
 
+
     /**
      * 创建时间
      */
@@ -97,6 +98,10 @@ public class OrderShopDto implements Serializable {
     @ApiModelProperty(value = "订单取消时间", required = false)
     private Date cancelTime;
 
+    @ApiModelProperty(value = "订单取消原因", required = true)
+    private String cancelReason;
+
+
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "订单更新时间", required = false)
     private Date updateTime;

+ 1 - 1
yami-shop-bean/src/main/java/com/yami/shop/bean/model/OrderRefundRecord.java

@@ -27,7 +27,7 @@ public class OrderRefundRecord {
     @ApiModelProperty(value = "修改时间")
     private Date updateTime;
 
-    @ApiModelProperty(value = "审核状态(1-申请原因,2-商家待审核,3-申请已通过,4-用户撤回申请, 5-用户待发货,7-待商家收货,10-审核通过,20-驳回,30-退款成功)")
+    @ApiModelProperty(value = "审核状态(1-申请原因,2-商家待审核,3-申请已通过,4-用户撤回申请, 5-用户待发货,7-待商家收货,10-审核通过,20-驳回,25-已收货,30-退款成功)")
     private Integer auditStatus;
 
     @ApiModelProperty(value = "排序")

+ 2 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/model/Product.java

@@ -208,6 +208,8 @@ public class Product implements Serializable {
     @TableField(exist = false)
     private String shopName;
 
+
+    //已售货数量
     @TableField(exist = false)
     private Integer salesVolume;
 

+ 2 - 0
yami-shop-security/yami-shop-security-api/src/main/java/com/yami/shop/security/api/service/impl/MaAppLoginServiceImpl.java

@@ -6,6 +6,7 @@ import com.yami.shop.config.WxConfig;
 import com.yami.shop.security.api.model.YamiUser;
 import com.yami.shop.security.api.service.AppLoginService;
 import com.yami.shop.security.api.service.YamiUserDetailsService;
+import com.yami.shop.security.api.util.SecurityUtils;
 import com.yami.shop.security.comment.enums.App;
 import com.yami.shop.security.comment.exception.WxErrorException;
 import com.yami.shop.security.comment.model.AppConnect;
@@ -42,6 +43,7 @@ public class MaAppLoginServiceImpl implements AppLoginService {
                 appConnect.setAppId(authentication.getAppType());
                 appConnect.setBizUserId(session.getOpenid());
                 appConnect.setBizUnionid(session.getUnionid());
+
                 appConnectService.save(appConnect);
             }
             YamiUser yamiUser = yamiUserDetailsService.loadUserByAppConnect(appConnect);

+ 5 - 10
yami-shop-service/src/main/java/com/yami/shop/service/impl/OrderRefundServiceImpl.java

@@ -1099,7 +1099,6 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
                     applyDeal = 1;
                 }
             }
-            Date date = new Date();
             OrderRefund orderRefund = orderRefundMapper.selectOne(new LambdaQueryWrapper<OrderRefund>().eq(OrderRefund::getRefundSn, afterSaleOrder));
             if (auditType == 3) {
                 //3:驳回
@@ -1112,13 +1111,12 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
                 orderByOrderNumber.setRefundStatus(4);
                 orderService.updateById(orderByOrderNumber);
 
-                //生成待商家审核记录
-                addOrderRefundRecord(orderRefund.getRefundId(), 20, 3, "reason");
+                //生成退款驳回记录
+                addOrderRefundRecord(orderRefund.getRefundId(), 20, 3, reason);
             } else {
                 //审核通过
                 orderRefund.setApplyType(applyDeal);
                 if (applyDeal == 1) {
-
                     orderRefund.setReturnMoneySts(ReturnMoneyStsType.SUCCESS.value());
                 } else {
                     //退货退款需要处理二审
@@ -1128,11 +1126,10 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
 
                 //生成待商家审核记录
                 if (applyDeal == 1) {
-                    addOrderRefundRecord(orderRefund.getRefundId(), 3, 3, "你的申请已通过,退款处理中");
+                    addOrderRefundRecord(orderRefund.getRefundId(), 5, 3, "你的申请已通过,退款处理中");
                 } else {
-                    addOrderRefundRecord(orderRefund.getRefundId(), 5, 3, "申请已通过,请及时填写配送信息并支付配送费");
+                    addOrderRefundRecord(orderRefund.getRefundId(), 6, 3, "申请已通过,请及时填写配送信息");
                 }
-
             }
 
             if (applyDeal == 1) {
@@ -1181,9 +1178,7 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
 
             //推送商家审核状态后 同步退款单状态
             changeStatus(orderRefund.getRefundSn(), orderRefund.getReturnMoneySts());
-            //生成待商家审核记录
-            addOrderRefundRecord(orderRefund.getRefundId(), 7, 5, "商家收到商品井确认不影响二次销售后,将会为您处理退款");
-        } catch (Exception e) {
+          } catch (Exception e) {
             log.error("海博退款订单查询异常:{}", e);
             HBR.error("未知异常");
         }

+ 24 - 11
yami-shop-service/src/main/java/com/yami/shop/service/impl/OrderServiceImpl.java

@@ -40,6 +40,7 @@ import com.yami.shop.bean.param.*;
 import com.yami.shop.common.config.Constant;
 import com.yami.shop.common.exception.GlobalException;
 import com.yami.shop.common.util.Arith;
+import com.yami.shop.common.util.Json;
 import com.yami.shop.common.util.PageAdapter;
 import com.yami.shop.common.util.PageParam;
 import com.yami.shop.dao.*;
@@ -210,7 +211,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         // 提交订单
         eventPublisher.publishEvent(new SubmitOrderEvent(mergerOrder, orderList));
         // 插入订单
-        orderList.forEach(orderMapper::insert);
+        orderList.forEach(c->{
+            if (c.getDvyType().equals(1) && c.getHbOrderStatus()!=0) {
+                c.setHbOrderStatus(1);
+            }
+            orderMapper.insert(c);
+        });
         List<OrderItem> orderItems = orderList.stream()
                 .flatMap(order -> order.getOrderItems().stream()
                 )
@@ -953,6 +959,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 .eq(OrderRefund::getReturnMoneySts, 70)
                 .eq(OrderRefund::getHandler, Boolean.FALSE)
         );
+        //生成待商家审核记录
+        addOrderRefundRecord(orderRefund.getRefundId(), 25, 6, "平台已退款到微信账户中");
+        addOrderRefundRecord(orderRefund.getRefundId(), 30, 10, "商家已同意收货,正在为你处理退款。");
+
+
         if (ObjectUtils.isNotEmpty(orderRefund)) {
             //退款的金额
             BigDecimal refundActual = BigDecimal.ZERO;
@@ -1222,19 +1233,21 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             log.info("退款单修改状态和积分{}",orderRefund);
             orderRefundMapper.updateById(orderRefund);
 
-            //生成待商家审核记录
-            OrderRefundRecord orderRefundRecord = new OrderRefundRecord();
-            orderRefundRecord.setOrderRefundId(orderRefund.getRefundId());
-            orderRefundRecord.setInstructions("商家收到商品并确认不影响二次销售后,将会为您处理退款");
-            Date date = new Date();
-            orderRefundRecord.setCreateTime(date);
-            orderRefundRecord.setUpdateTime(date);
-            orderRefundRecord.setAuditStatus(5);
-            orderRefundRecord.setSort(4);
-            orderRefundRecordMapper.insert(orderRefundRecord);
         }
     }
 
+    private void addOrderRefundRecord(Long refundId, Integer auditStatus, Integer sort, String instructions) {
+        OrderRefundRecord orderRefundRecord = new OrderRefundRecord();
+        orderRefundRecord.setOrderRefundId(refundId);
+        orderRefundRecord.setInstructions(instructions);
+        Date date = new Date();
+        orderRefundRecord.setCreateTime(date);
+        orderRefundRecord.setUpdateTime(date);
+        orderRefundRecord.setAuditStatus(auditStatus);
+        orderRefundRecord.setSort(sort);
+        orderRefundRecordMapper.insert(orderRefundRecord);
+    }
+
     @Override
     public OrderRefundAmountDTO computeOrderRefundAmount(String orderNumber, List<OrderRefundAmountParam> suk) {
         BigDecimal orderRefundAmount = BigDecimal.ZERO;

+ 1 - 1
yami-shop-service/src/main/resources/mapper/OrderRefundMapper.xml

@@ -518,7 +518,7 @@
         where refund.refund_id = #{refundId}
     </select>
     <select id="findByOrderNumber" resultType="com.yami.shop.bean.model.OrderRefund">
-        select * from tz_order_refund where return_money_sts=#{returnMoneySts} and order_number =#{orderNumber} and handler =0
+        select * from tz_order_refund where return_money_sts=#{returnMoneySts} and order_number =#{orderNumber}
     </select>
 
 </mapper>

+ 17 - 1
yami-shop-service/src/main/resources/mapper/ProductMapper.xml

@@ -819,7 +819,23 @@
             tp.activity_id,
             tp.sup_id,
             tp.hb_spu_id,
-            tp.hb_status
+            tp.hb_status,
+
+            COALESCE ((
+                          SELECT
+                              SUM( oi2.prod_count )
+                          FROM
+                              tz_order_item oi2
+                                  INNER JOIN tz_order o2 ON o2.order_number = oi2.order_number
+                          WHERE
+                              oi2.shop_id = #{prodByCategoryIdAndShopIdDTO.shopId}
+                            AND oi2.prod_id = tp.prod_id
+                            AND o2.hb_order_status IN ( 20, 30, 40, 70, 80 )
+                            AND o2.delete_status = 0
+                      ),
+                      0
+            ) AS salesVolume
+
         FROM tz_prod tp
                  INNER JOIN tz_category_prod tcp ON tp.prod_id = tcp.prod_id
                    AND tcp.is_delete = 0 AND tcp.shop_id = #{prodByCategoryIdAndShopIdDTO.shopId}