he2802 před 2 roky
rodič
revize
c51b77f454

+ 3 - 0
zhongzheng-admin-saas/src/main/resources/application.yml

@@ -303,3 +303,6 @@ aliyun:
     todayExamNotRecordWarn: SMS_257713140  #学员打卡提醒(每日一练)
     todayExamNotRecordTeachWarn: SMS_257702971  #学员打卡教务提醒(每日一练)
     noFinishExamNoteCode: SMS_262460267  #未做完试卷通知
+
+distributionOldPay:
+      host: http://test.jqbao.net/System/BussinessApi/AddRedPackData

+ 11 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/distribution/DistributionActivityController.java

@@ -136,5 +136,16 @@ public class DistributionActivityController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 佣金列表
+     */
+    @ApiOperation("佣金列表")
+    @GetMapping("/cash/list")
+    public TableDataInfo<SellerOrderVo> getCashList(SellerOrderQueryBo bo) {
+        startPage();
+        List<SellerOrderVo> list = iDistributionActivityService.getSellerOrder(bo);
+        return getDataTable(list);
+    }
+
 
 }

+ 12 - 2
zhongzheng-admin/src/main/java/com/zhongzheng/controller/distribution/DistributionSellerController.java

@@ -12,10 +12,10 @@ import com.zhongzheng.framework.web.service.WxLoginService;
 import com.zhongzheng.modules.distribution.bo.DistributionSellerAddBo;
 import com.zhongzheng.modules.distribution.bo.DistributionSellerEditBo;
 import com.zhongzheng.modules.distribution.bo.DistributionSellerQueryBo;
+import com.zhongzheng.modules.distribution.bo.SellerOrderQueryBo;
 import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
 import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
-import com.zhongzheng.modules.user.bo.UserVisitLogAddBo;
-import com.zhongzheng.modules.user.entity.ClientLoginSeller;
+import com.zhongzheng.modules.distribution.vo.SellerOrderVo;
 import com.zhongzheng.modules.wx.bo.WxLoginBody;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -148,4 +148,14 @@ public class DistributionSellerController extends BaseController {
         return AjaxResult.success();
     }
 
+    @ApiOperation("业务员佣金")
+    @GetMapping("/cash/list")
+    public TableDataInfo<SellerOrderVo> getCashList(SellerOrderQueryBo bo) {
+        startPage();
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setSellerId(loginUser.getUser().getSellerId());
+        List<SellerOrderVo> list = iDistributionSellerService.getCashList(bo);
+        return getDataTable(list);
+    }
+
 }

+ 12 - 2
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/DistributionSellerServiceImpl.java

@@ -20,17 +20,17 @@ import com.zhongzheng.common.exception.BaseException;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.type.EncryptHandler;
 import com.zhongzheng.common.utils.*;
-import com.zhongzheng.common.utils.ip.IpUtils;
 import com.zhongzheng.modules.distribution.bo.*;
 import com.zhongzheng.modules.distribution.domain.DistributionSeller;
 import com.zhongzheng.modules.distribution.mapper.DistributionSellerMapper;
+import com.zhongzheng.modules.distribution.service.IDistributionActivityService;
 import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
 import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
+import com.zhongzheng.modules.distribution.vo.SellerOrderVo;
 import com.zhongzheng.modules.system.service.ISysRoleService;
 import com.zhongzheng.modules.system.service.ISysUserService;
 import com.zhongzheng.modules.top.distribution.bo.DistributionSellerQuery;
 import com.zhongzheng.modules.user.domain.User;
-import com.zhongzheng.modules.user.entity.ClientLoginUser;
 import com.zhongzheng.modules.user.service.IUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -68,6 +68,9 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
     @Autowired
     private ISysRoleService iSysRoleService;
 
+    @Autowired
+    private IDistributionActivityService iDistributionActivityService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean registerSeller(SellerAppRegisterBo bo) {
@@ -277,6 +280,8 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
         map.put("full_info", Validator.isEmpty(sysUser.getIdCard()) ? false : true); //是否完善身份信息
         return map;
     }
+
+    @Override
     public List<DistributionSellerVo> getSellerListByTenant(DistributionSellerQuery query) {
         return baseMapper.getSellerListByTenant(query);
     }
@@ -472,4 +477,9 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
         return tokenService.createToken(loginSeller);
     }
 
+    @Override
+    public List<SellerOrderVo> getCashList(SellerOrderQueryBo bo) {
+        return iDistributionActivityService.getSellerOrder(bo);
+    }
+
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/domain/DistributionRebate.java

@@ -46,7 +46,7 @@ private static final long serialVersionUID=1L;
     private BigDecimal profit;
     /** 状态:1有效,0无效 */
     private Integer status;
-    /** 佣金状态:1冻结,2正常 */
+    /** 佣金状态:1冻结,2正常, 3退款*/
     private Integer cashStatus;
     /** 解冻时间 */
     private Long openTime;

+ 2 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/service/IDistributionSellerService.java

@@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.distribution.bo.*;
 import com.zhongzheng.modules.distribution.domain.DistributionSeller;
 import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
-import com.zhongzheng.modules.user.bo.UserAppAccountLoginBo;
-import com.zhongzheng.modules.user.bo.UserAppForgetBo;
-import com.zhongzheng.modules.user.bo.UserAppRegisterBo;
-import com.zhongzheng.modules.user.bo.UserAppSmsLoginBo;
+import com.zhongzheng.modules.distribution.vo.SellerOrderVo;
 import com.zhongzheng.modules.top.distribution.bo.DistributionSellerQuery;
 import com.zhongzheng.modules.user.domain.User;
 
@@ -78,4 +75,5 @@ public interface IDistributionSellerService extends IService<DistributionSeller>
 
 	String refreshSellerToken(String userAccount);
 
+    List<SellerOrderVo> getCashList(SellerOrderQueryBo bo);
 }

+ 38 - 10
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/service/impl/DistributionActivityServiceImpl.java

@@ -16,15 +16,9 @@ import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.modules.activity.domain.ActivityGoodsPrice;
 import com.zhongzheng.modules.activity.service.IActivityGoodsPriceService;
 import com.zhongzheng.modules.distribution.bo.*;
-import com.zhongzheng.modules.distribution.domain.DistributionActivity;
-import com.zhongzheng.modules.distribution.domain.DistributionActivityGoods;
-import com.zhongzheng.modules.distribution.domain.DistributionActivityPoster;
-import com.zhongzheng.modules.distribution.domain.DistributionCashLog;
+import com.zhongzheng.modules.distribution.domain.*;
 import com.zhongzheng.modules.distribution.mapper.DistributionActivityMapper;
-import com.zhongzheng.modules.distribution.service.IDistributionActivityGoodsService;
-import com.zhongzheng.modules.distribution.service.IDistributionActivityPosterService;
-import com.zhongzheng.modules.distribution.service.IDistributionActivityService;
-import com.zhongzheng.modules.distribution.service.IDistributionCashLogService;
+import com.zhongzheng.modules.distribution.service.*;
 import com.zhongzheng.modules.distribution.vo.DistributionActivityGoodsVo;
 import com.zhongzheng.modules.distribution.vo.DistributionActivityVo;
 import com.zhongzheng.modules.distribution.vo.DistributionGoodsListVo;
@@ -41,6 +35,7 @@ import com.zhongzheng.modules.top.distribution.domain.DistributionActivityTempla
 import com.zhongzheng.modules.top.distribution.domain.DistributionActivityTemplateGoods;
 import com.zhongzheng.modules.top.distribution.service.IDistributionActivityTemplateGoodsService;
 import com.zhongzheng.modules.top.distribution.service.IDistributionActivityTemplateService;
+import com.zhongzheng.modules.top.distribution.vo.TenantOrderCashVo;
 import com.zhongzheng.modules.top.distribution.vo.TenantOrderVo;
 import com.zhongzheng.modules.top.distribution.vo.TenantSortNoticeVo;
 import com.zhongzheng.modules.top.goods.domain.TopActivityGoodsPrice;
@@ -89,6 +84,10 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
     private IGoodsSpecAttributeRelationService goodsSpecAttributeRelationService;
     @Autowired
     private IDistributionCashLogService iDistributionCashLogService;
+    @Autowired
+    private IDistributionRebateService iDistributionRebateService;
+    @Autowired
+    private IDistributionSellerService iDistributionSellerService;
 
     @Override
     public DistributionActivityVo queryById(Long distributionId){
@@ -439,7 +438,7 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
             //商品活动价格
             ActivityGoodsPrice goodsPrice = iActivityGoodsPriceService
                     .getOne(new LambdaQueryWrapper<ActivityGoodsPrice>()
-                    .eq(ActivityGoodsPrice::getActivityCode, item.getCode())
+                    .eq(ActivityGoodsPrice::getActivityCode, item.getDistributionCode())
                     .eq(ActivityGoodsPrice::getGoodsId, item.getGoodsId())
                     .eq(ActivityGoodsPrice::getStatus, 1)
                     .last("limit 1"));
@@ -472,6 +471,10 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
             return new ArrayList<>();
         }
         orderVos.forEach(item -> {
+//            if (item.getCashType() == 1){
+//                //百分比
+//                item.setCashRatio(item.getCashRatio().multiply(new BigDecimal("100.00")));
+//            }
             //差看佣金状态
             DistributionCashLog cashLog = iDistributionCashLogService
                     .getOne(new LambdaQueryWrapper<DistributionCashLog>()
@@ -493,6 +496,31 @@ public class DistributionActivityServiceImpl extends ServiceImpl<DistributionAct
     @Override
     public List<TenantOrderVo> getOrgOrder(TenantOrderQueryBo bo) {
         List<TenantOrderVo> orderVos = baseMapper.getOrgOrder(bo);
-        return null;
+        if (CollectionUtils.isEmpty(orderVos)){
+            return new ArrayList<>();
+        }
+        orderVos.forEach(item -> {
+            //佣金详情
+            List<DistributionRebate> list = iDistributionRebateService
+                    .list(new LambdaQueryWrapper<DistributionRebate>()
+                    .eq(DistributionRebate::getOrderSn, item.getOrderSn())
+                    .eq(DistributionRebate::getStatus,1));
+            if (CollectionUtils.isNotEmpty(list)){
+                List<TenantOrderCashVo> cashVoList = list.stream().map(rebate -> {
+                    TenantOrderCashVo cashVo = new TenantOrderCashVo();
+                    cashVo.setSellerId(rebate.getSellerId());
+                    cashVo.setCash(rebate.getCash());
+                    cashVo.setCashStatus(rebate.getCashStatus());
+                    cashVo.setCashTime(rebate.getCreateTime());
+                    cashVo.setCashType(rebate.getProfitType());
+                    cashVo.setCashRatio(rebate.getProfit());
+                    DistributionSeller seller = iDistributionSellerService.getById(rebate.getSellerId());
+                    cashVo.setSellerName(seller.getRealname());
+                    return cashVo;
+                }).collect(Collectors.toList());
+                item.setCashVoList(cashVoList);
+            }
+        });
+        return orderVos;
     }
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/vo/SellerOrderVo.java

@@ -66,4 +66,7 @@ public class SellerOrderVo implements Serializable {
     /** 商品ID */
     @ApiModelProperty("商品ID")
     private Long goodsId;
+    /** 订单商品ID */
+    @ApiModelProperty("订单商品ID")
+    private Long orderGoodsId;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsRefundServiceImpl.java

@@ -719,6 +719,9 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
             seller.setFreezeCash(freezeCash);
             seller.setUpdateTime(DateUtils.getNowTime());
             iDistributionSellerService.updateById(seller);
+            //修改佣金状态
+            rebate.setCashStatus(3);
+            iDistributionRebateService.updateById(rebate);
         });
         iDistributionCashLogService.updateBatchById(cashLogList);
     }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/distribution/vo/TenantOrderVo.java

@@ -61,6 +61,9 @@ public class TenantOrderVo implements Serializable {
     /** 所属机构 */
     @ApiModelProperty("所属机构")
     private String tenantName;
+    /** 所属机构ID */
+    @ApiModelProperty("所属机构ID")
+    private Long tenantId;
     /** 佣金详情 */
     @ApiModelProperty("佣金详情")
     private List<TenantOrderCashVo> cashVoList;

+ 15 - 7
zhongzheng-system/src/main/resources/mapper/modules/distribution/DistributionActivityMapper.xml

@@ -45,7 +45,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         dr.create_time as cashTime,
         dr.seller_id,
         dr.profit_type as cashType,
-        dr.profit as cashRatio
+        dr.profit as cashRatio,
+        dr.order_goods_id
         FROM
         distribution_rebate dr
         LEFT JOIN order_goods og ON dr.order_goods_id = og.order_goods_id
@@ -103,20 +104,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             o.order_sn,
             o.order_status,
             og.pay_status,
-            d.`name`,
+            d.`name` as distributionName,
             d.distribution_id,
-            d.`code`,
-            u.realname,
+            d.`code` as distributionCode,
+            u.realname as orderUserName,
             u.telphone,
-            o.create_time,
-            og.goods_real_price,
+            o.create_time as orderTime,
+            og.goods_real_price as orderPrice,
             g.goods_id,
             g.goods_name,
             t.tenant_id,
             t.tenant_name,
             (SELECT SUM(cash) FROM distribution_rebate WHERE order_sn = og.order_sn GROUP BY order_sn) AS orderCash
         FROM
-                (SELECT DISTINCT(order_goods_id) FROM distribution_rebate) dr
+                (SELECT DISTINCT(dre.order_goods_id) FROM distribution_rebate dre
+                    <if test = "sellerName != null and sellerName != ''" >
+                        LEFT JOIN distribution_seller ds ON dre.seller_id = ds.seller_id WHERE ds.realname LIKE concat('%', #{sellerName}, '%')
+                    </if >
+                    ) dr
                     LEFT JOIN order_goods og ON dr.order_goods_id = og.order_goods_id
                     LEFT JOIN `order` o ON og.order_sn = o.order_sn
                     LEFT JOIN `user` u ON o.user_id = u.user_id
@@ -136,6 +141,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test = "orderSn != null and orderSn != ''" >
             AND og.`order` = #{orderSn}
         </if >
+        <if test = "userName != null and userName != ''" >
+            AND u.realname like concat('%', #{userName}, '%')
+        </if >
     </select>
 
 </mapper>