he2802 há 2 anos atrás
pai
commit
a0aec787a6

+ 2 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/distribution/DistributionCashWithdrawalController.java

@@ -53,6 +53,8 @@ public class DistributionCashWithdrawalController extends BaseController {
     @PreAuthorize("@ss.hasPermi('system:withdrawal:list')")
     @GetMapping("/list")
     public TableDataInfo<DistributionCashWithdrawalVo> list(DistributionCashWithdrawalQueryBo bo) {
+        ClientLoginSeller loginUser = sellerTokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setSellerId(loginUser.getSeller().getSellerId());
         startPage();
         List<DistributionCashWithdrawalVo> list = iDistributionCashWithdrawalService.queryList(bo);
         return getDataTable(list);

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

@@ -147,7 +147,7 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
         DistributionSeller sellerSync = new DistributionSeller();
         sellerSync.setUserId(seller.getUserId());
         sellerSync.setPassword(seller.getPassword());
-        syncSellerToUser(sellerSync,null,1);
+    //    syncSellerToUser(sellerSync,null,1);
         return updateById(seller);
     }
 
@@ -353,7 +353,6 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
         inertData.setIdCard(bo.getIdCard());
         inertData.setRealname(bo.getRealname());
         inertData.setAvatar(Constants.DEFAULT_AVATAR);
-        inertData.setPassword(SecurityUtils.encryptPassword(bo.getPassword()));
         inertData.setUserAccount(ServletUtils.getEncoded("YW"));
         inertData.setCreateTime(DateUtils.getNowTime());
         inertData.setUpdateTime(DateUtils.getNowTime());

+ 58 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/service/impl/DistributionCashWithdrawalServiceImpl.java

@@ -1,21 +1,32 @@
 package com.zhongzheng.modules.distribution.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.exception.CustomException;
+import com.zhongzheng.common.type.EncryptHandler;
 import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.distribution.bo.DistributionCashLogAddBo;
 import com.zhongzheng.modules.distribution.bo.DistributionCashWithdrawalAddBo;
 import com.zhongzheng.modules.distribution.bo.DistributionCashWithdrawalEditBo;
 import com.zhongzheng.modules.distribution.bo.DistributionCashWithdrawalQueryBo;
 import com.zhongzheng.modules.distribution.domain.DistributionCashWithdrawal;
+import com.zhongzheng.modules.distribution.domain.DistributionSeller;
 import com.zhongzheng.modules.distribution.mapper.DistributionCashWithdrawalMapper;
+import com.zhongzheng.modules.distribution.service.IDistributionCashLogService;
 import com.zhongzheng.modules.distribution.service.IDistributionCashWithdrawalService;
+import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
 import com.zhongzheng.modules.distribution.vo.DistributionCashWithdrawalVo;
+import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
+import com.zhongzheng.modules.user.domain.User;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.Page;
 
+import java.math.BigDecimal;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -30,6 +41,12 @@ import java.util.stream.Collectors;
 @Service
 public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<DistributionCashWithdrawalMapper, DistributionCashWithdrawal> implements IDistributionCashWithdrawalService {
 
+    @Autowired
+    private IDistributionSellerService iDistributionSellerService;
+
+    @Autowired
+    private IDistributionCashLogService iDistributionCashLogService;
+
     @Override
     public DistributionCashWithdrawalVo queryById(Long id){
         DistributionCashWithdrawal db = this.baseMapper.selectById(id);
@@ -73,12 +90,53 @@ public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<Distribut
 
     @Override
     public Boolean insertByAddBo(DistributionCashWithdrawalAddBo bo) {
+        if(Validator.isEmpty(bo.getCash())||(bo.getCash().compareTo(BigDecimal.ZERO) == 0)){
+            throw new CustomException("金额需大于0");
+        }
         DistributionCashWithdrawal add = BeanUtil.toBean(bo, DistributionCashWithdrawal.class);
+        DistributionSeller seller = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
+                .eq(DistributionSeller::getSellerId, bo.getSellerId()).last("limit 1"));
+        if(bo.getCash().compareTo(seller.getCash())== 1){
+            throw new CustomException("可提现金额不足");
+        }
+        //生成申请号
+        String cw_no = "CW"+DateUtils.getDateOrderSn();
+        BigDecimal oldCash = seller.getCash();
+        BigDecimal newCash = seller.getCash().subtract(bo.getCash());
+        //可提现日志
+        DistributionCashLogAddBo cashLogAddBo = new DistributionCashLogAddBo();
+        cashLogAddBo.setSellerId(add.getSellerId());
+        cashLogAddBo.setOldNum(oldCash);
+        cashLogAddBo.setNewNum(newCash);
+        cashLogAddBo.setDiffNum(bo.getCash());
+        cashLogAddBo.setRelatedSn(cw_no);
+        cashLogAddBo.setType(2L);
+        iDistributionCashLogService.insertByAddBo(cashLogAddBo);
+        BigDecimal oldUsedCash = seller.getUsedCash();
+        BigDecimal newUsedCash = seller.getUsedCash().add(bo.getCash());
+        //已提现日志
+        DistributionCashLogAddBo usedCashLogAddBo = new DistributionCashLogAddBo();
+        usedCashLogAddBo.setSellerId(add.getSellerId());
+        usedCashLogAddBo.setOldNum(oldUsedCash);
+        usedCashLogAddBo.setNewNum(newUsedCash);
+        usedCashLogAddBo.setDiffNum(bo.getCash());
+        usedCashLogAddBo.setRelatedSn(cw_no);
+        usedCashLogAddBo.setType(3L);
+        iDistributionCashLogService.insertByAddBo(usedCashLogAddBo);
+
+        seller.setCash(newCash);
+        seller.setUsedCash(newUsedCash);
+        seller.setUpdateTime(DateUtils.getNowTime());
+        iDistributionSellerService.updateById(seller);
         validEntityBeforeSave(add);
+
+        add.setCwSn(cw_no);
         add.setCwStatus(0);
         add.setCreateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());
         add.setApplyTime(DateUtils.getNowTime());
+
+
         return this.save(add);
     }
 

+ 4 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/vo/DistributionSellerVo.java

@@ -91,9 +91,12 @@ public class DistributionSellerVo {
 	@ApiModelProperty("邀请人编号	")
 	private String parentAccount;
 
-	@ApiModelProperty("推广人数	")
+	@ApiModelProperty("推广人数")
 	private String promotionNum;
 
+	@ApiModelProperty("成交订单客户数")
+	private String orderPeopleNum;
+
 	@ApiModelProperty("所属机构")
 	private String tenantName;
 	/** 可提现余额(不含冻结) */

+ 5 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/impl/WxPayServiceImpl.java

@@ -416,13 +416,13 @@ public class WxPayServiceImpl implements IWxPayService {
         initData();
         String key = "gzh_ticket";
         String ticket = redisCache.getCacheObject(key);
-        if (!Validator.isNotNull(ticket)) {
+        if (!Validator.isEmpty(ticket)||ticket.equals("null")) {
             String access_token = wx_get_token();
             String param = String.format("access_token=%s&type=jsapi", access_token);
             String resultString = HttpUtils.sendGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket", param);
             JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
             ticket = String.valueOf(jsonObject.get("ticket"));
-            if (ticket != null) {
+            if (ticket != null&&!ticket.equals("null")) {
                 redisCache.setCacheObject(key, ticket, 2 * 50, TimeUnit.MINUTES);//2个小时
             }
         }
@@ -434,17 +434,17 @@ public class WxPayServiceImpl implements IWxPayService {
         initData();
         String key = "gzh_access_token";
         String access_token = redisCache.getCacheObject(key);
-        if (!Validator.isNotNull(access_token)) {
+        if (Validator.isEmpty(access_token)||access_token.equals("null")) {
             String param = String.format(gzh_tokenParam, gzhAppid, gzh_appsrcret);
             String resultString = HttpUtils.sendGet(gzh_tokenUrl, param);
             //解析json
             JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
             access_token = String.valueOf(jsonObject.get("access_token"));  //这里应该把access_token缓存起来,至于要怎么缓存就看各位了,有效期是7200s
-            if (access_token != null) {
+            if (access_token != null&&!access_token.equals("null")) {
                 redisCache.setCacheObject(key, access_token, 2 * 50, TimeUnit.MINUTES);//2个小时
             }
         }
-        if (!Validator.isNotNull(access_token)) {
+        if (Validator.isEmpty(access_token)||access_token.equals("null")) {
             throw new CustomException("access_token错误" + access_token);
         }
         return access_token;