Browse Source

1、缴费积分抵扣从小区设置里面配置并且进行抵扣2、抵扣明细3、超时相关bug

xiaogang 3 years ago
parent
commit
75cbaa2d0c

+ 9 - 2
java110-bean/src/main/java/com/java110/dto/accountDetail/AccountDetailDto.java

@@ -33,7 +33,7 @@ public class AccountDetailDto extends PageDto implements Serializable {
     private String remark;
     private String objType;
     private String acctType;
-
+    private String bId;
 
     private Date createTime;
 
@@ -112,7 +112,6 @@ public class AccountDetailDto extends PageDto implements Serializable {
         this.objType = objType;
     }
 
-
     public Date getCreateTime() {
         return createTime;
     }
@@ -144,4 +143,12 @@ public class AccountDetailDto extends PageDto implements Serializable {
     public void setAcctType(String acctType) {
         this.acctType = acctType;
     }
+
+    public String getbId() {
+        return bId;
+    }
+
+    public void setbId(String bId) {
+        this.bId = bId;
+    }
 }

+ 26 - 0
java110-bean/src/main/java/com/java110/po/accountDetail/AccountDetailPo.java

@@ -1,6 +1,7 @@
 package com.java110.po.accountDetail;
 
 import java.io.Serializable;
+import java.util.Date;
 
 public class AccountDetailPo implements Serializable {
 
@@ -13,6 +14,9 @@ public class AccountDetailPo implements Serializable {
     private String relAcctId;
     private String remark;
     private String objType;
+    private String bId;
+    private Date createTime;
+    private String statusCd = "0";
 
     public String getDetailType() {
         return detailType;
@@ -86,5 +90,27 @@ public class AccountDetailPo implements Serializable {
         this.objType = objType;
     }
 
+    public String getbId() {
+        return bId;
+    }
+
+    public void setbId(String bId) {
+        this.bId = bId;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
 
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getStatusCd() {
+        return statusCd;
+    }
+
+    public void setStatusCd(String statusCd) {
+        this.statusCd = statusCd;
+    }
 }

+ 2 - 2
java110-db/src/main/resources/mapper/fee/FeePrintSpecServiceDaoImplMapper.xml

@@ -54,7 +54,7 @@
         <if test="newBId != null and newBId != ''">
             ,t.b_id = #{newBId}
         </if>
-        <if test="content !=null and content != ''">
+        <if test="content !=null">
             , t.content= #{content}
         </if>
         <if test="specCd !=null and specCd != ''">
@@ -63,7 +63,7 @@
         <if test="communityId !=null and communityId != ''">
             , t.community_id= #{communityId}
         </if>
-        <if test="qrImg !=null and qrImg != ''">
+        <if test="qrImg !=null">
             , t.qr_img= #{qrImg}
         </if>
         <if test="printName !=null and printName != ''">

+ 0 - 2
service-api/src/main/java/com/java110/api/listener/fee/PayFeePreListener.java

@@ -238,13 +238,11 @@ public class PayFeePreListener extends AbstractServiceApiDataFlowListener {
                     }
                 }
             }
-
         }
         if (responseEntity.getStatusCode() != HttpStatus.OK) {
             dataFlowContext.setResponseEntity(responseEntity);
             return;
         }
-
         JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
         //这里调整为实收金额
         paramOut.put("receivableAmount", paramObj.getString("receivableAmount"));

+ 1 - 2
service-api/src/main/java/com/java110/api/smo/payment/impl/ToNotifySMOImpl.java

@@ -17,12 +17,11 @@ import javax.servlet.http.HttpServletRequest;
 
 @Service("toNotifySMOImpl")
 public class ToNotifySMOImpl implements IToNotifySMO {
-    private static final Logger logger = LoggerFactory.getLogger(AppAbstractComponentSMO.class);
 
+    private static final Logger logger = LoggerFactory.getLogger(AppAbstractComponentSMO.class);
 
     private static final String DEFAULT_PAY_NOTIFY_ADAPT = "wechatPayNotifyAdapt";// 默认微信通用支付
 
-
     @Override
     public ResponseEntity<String> toNotify(String param, HttpServletRequest request) {
 

+ 156 - 2
service-api/src/main/java/com/java110/api/smo/payment/impl/ToPaySMOImpl.java

@@ -8,10 +8,17 @@ import com.java110.api.smo.payment.IToPaySMO;
 import com.java110.api.smo.payment.adapt.IPayAdapt;
 import com.java110.core.context.IPageData;
 import com.java110.core.context.PageData;
+import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.core.log.LoggerFactory;
 import com.java110.dto.app.AppDto;
 import com.java110.dto.owner.OwnerAppUserDto;
 import com.java110.dto.smallWeChat.SmallWeChatDto;
+import com.java110.intf.acct.IAccountDetailInnerServiceSMO;
+import com.java110.intf.acct.IAccountInnerServiceSMO;
+import com.java110.intf.feeAccountDetail.IFeeAccountDetailServiceSMO;
+import com.java110.po.account.AccountPo;
+import com.java110.po.accountDetail.AccountDetailPo;
+import com.java110.po.feeAccountDetail.FeeAccountDetailPo;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.constant.WechatConstant;
@@ -29,6 +36,7 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -45,10 +53,18 @@ public class ToPaySMOImpl extends AppAbstractComponentSMO implements IToPaySMO {
     @Autowired
     private RestTemplate outRestTemplate;
 
-
     @Autowired
     private WechatAuthProperties wechatAuthProperties;
 
+    @Autowired
+    private IAccountInnerServiceSMO accountInnerServiceSMOImpl;
+
+    @Autowired
+    private IAccountDetailInnerServiceSMO accountDetailInnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeAccountDetailServiceSMO feeAccountDetailServiceSMOImpl;
+
     @Override
     public ResponseEntity<String> toPay(IPageData pd) {
         return super.businessProcess(pd);
@@ -93,7 +109,7 @@ public class ToPaySMOImpl extends AppAbstractComponentSMO implements IToPaySMO {
         String orderId = orderInfo.getString("oId");
         String feeName = orderInfo.getString("feeName");
         double money = Double.parseDouble(orderInfo.getString("receivedAmount"));
-        //需要判断金额是否 == 0 等于0 直接缴费通知接口
+        //需要判断金额是否 == 0 等于0 直接缴费通知接口
         if (money <= 0) {
             JSONObject paramOut = new JSONObject();
             paramOut.put("oId", orderId);
@@ -109,6 +125,144 @@ public class ToPaySMOImpl extends AppAbstractComponentSMO implements IToPaySMO {
             if (ResultVo.CODE_OK != result.getInteger("code")) {
                 return responseEntity;
             }
+            if (paramIn.containsKey("selectUserAccount") && !StringUtil.isEmpty(paramIn.getString("selectUserAccount"))) {
+                String selectUserAccount = paramIn.getString("selectUserAccount");
+                JSONArray params = JSONArray.parseArray(selectUserAccount);
+                for (int paramIndex = 0; paramIndex < params.size(); paramIndex++) {
+                    JSONObject paramObj = params.getJSONObject(paramIndex);
+                    if (!StringUtil.isEmpty(paramObj.getString("acctType")) && paramObj.getString("acctType").equals("2004")) { //积分账户
+                        //账户金额
+                        BigDecimal amount = new BigDecimal(paramObj.getString("amount"));
+                        //获取最大抵扣积分
+                        BigDecimal maximumNumber = new BigDecimal(paramObj.getString("maximumNumber"));
+                        //获取积分抵扣比例
+                        BigDecimal deductionProportion = new BigDecimal(paramObj.getString("deductionProportion"));
+                        int flag = amount.compareTo(maximumNumber);
+                        BigDecimal redepositAmount = new BigDecimal("0.00");
+                        BigDecimal integralAmount = new BigDecimal("0.00");
+                        if (flag == 1) { //账户积分大于最大使用积分,就用最大使用积分抵扣
+                            redepositAmount = maximumNumber;
+                            integralAmount = amount.subtract(maximumNumber);
+                        }
+                        if (flag > -1) { //账户积分大于等于最大使用积分,就用最大使用积分抵扣
+                            redepositAmount = maximumNumber;
+                            integralAmount = amount.subtract(maximumNumber);
+                        }
+                        if (flag == -1) { //账户积分小于最大使用积分,就用账户积分抵扣
+                            redepositAmount = amount;
+                        }
+                        if (flag < 1) { //账户积分小于等于最大使用积分,就用账户积分抵扣
+                            redepositAmount = amount;
+                        }
+                        if (flag == 0) { //账户积分等于最大使用积分
+                            redepositAmount = amount;
+                        }
+                        //更新账户信息
+                        AccountPo accountPo = new AccountPo();
+                        accountPo.setAcctId(paramObj.getString("acctId"));
+                        accountPo.setAmount(integralAmount.toString());
+                        accountInnerServiceSMOImpl.updateAccount(accountPo);
+                        //生成账户详情
+                        AccountDetailPo accountDetailPo = new AccountDetailPo();
+                        accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
+                        accountDetailPo.setAcctId(paramObj.getString("acctId"));
+                        accountDetailPo.setDetailType("2002"); //1001 转入 2002 转出
+                        accountDetailPo.setRelAcctId("-1");
+                        accountDetailPo.setAmount(redepositAmount.toString());
+                        accountDetailPo.setObjType("6006"); //6006 个人 7007 商户
+                        accountDetailPo.setObjId(paramObj.getString("objId"));
+                        accountDetailPo.setOrderId("-1");
+                        accountDetailPo.setbId("-1");
+                        accountDetailPo.setRemark("手机端积分抵扣");
+                        accountDetailPo.setCreateTime(new Date());
+                        accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo);
+                        //计算积分换算的金额
+                        BigDecimal divide = redepositAmount.divide(deductionProportion);
+                        BigDecimal deductionAmount = new BigDecimal(paramIn.getString("deductionAmount"));
+                        //计算实付金额
+                        int flag2 = divide.compareTo(deductionAmount);
+                        BigDecimal subtract = new BigDecimal("0.00");
+                        //生成抵扣明细记录
+                        FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo();
+                        if (flag2 == -1) { //积分换算金额小于应付金额
+                            subtract = deductionAmount.subtract(divide);
+                            BigDecimal multiply = divide.multiply(deductionProportion);
+                            feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额
+                        } else if (flag < 1) { //积分换算金额小于等于应付金额
+                            subtract = deductionAmount.subtract(divide);
+                            BigDecimal multiply = divide.multiply(deductionProportion);
+                            feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额
+                        } else {
+                            BigDecimal multiply = deductionAmount.multiply(deductionProportion);
+                            feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额
+                        }
+                        paramIn.put("receivedMoney", subtract);
+//                    payFeeDetailPo.setReceivedAmount(subtract.toString());
+                        feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId));
+                        feeAccountDetailPo.setDetailId(accountDetailPo.getDetailId());
+                        feeAccountDetailPo.setCommunityId(paramObj.getString("communityId"));
+                        feeAccountDetailPo.setState("1003"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣
+                        feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo);
+                    } else if (!StringUtil.isEmpty(paramObj.getString("acctType")) && paramObj.getString("acctType").equals("2003")) { //现金账户
+                        //账户金额
+                        BigDecimal amount = new BigDecimal(paramObj.getString("amount"));
+                        //获取应收金额
+                        BigDecimal deductionAmount = new BigDecimal("0.00");
+                        if (paramIn.containsKey("receivedMoney") && !StringUtil.isEmpty(paramIn.getString("receivedMoney"))) {
+                            deductionAmount = new BigDecimal(paramIn.getString("receivedMoney"));
+                        } else {
+                            deductionAmount = new BigDecimal(paramIn.getString("deductionAmount"));
+                        }
+                        int flag = amount.compareTo(deductionAmount);
+                        BigDecimal redepositAmount = new BigDecimal("0.00");
+                        BigDecimal integralAmount = new BigDecimal("0.00");
+                        if (flag == 1) { //现金账户大于应收金额,就用应收金额抵扣
+                            redepositAmount = deductionAmount;
+                            integralAmount = amount.subtract(deductionAmount);
+                        }
+                        if (flag > -1) { //现金账户大于等于应收金额,就用应收金额抵扣
+                            redepositAmount = deductionAmount;
+                            integralAmount = amount.subtract(deductionAmount);
+                        }
+                        if (flag == -1) { //现金账户小于实收金额,就用现金账户抵扣
+                            redepositAmount = amount;
+                        }
+                        if (flag < 1) { //现金账户小于等于应收金额,就用现金账户抵扣
+                            redepositAmount = amount;
+                        }
+                        if (flag == 0) { //现金账户等于应收金额
+                            redepositAmount = amount;
+                        }
+                        //更新账户信息
+                        AccountPo accountPo = new AccountPo();
+                        accountPo.setAcctId(paramObj.getString("acctId"));
+                        accountPo.setAmount(integralAmount.toString());
+                        accountInnerServiceSMOImpl.updateAccount(accountPo);
+                        //生成账户详情
+                        AccountDetailPo accountDetailPo = new AccountDetailPo();
+                        accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
+                        accountDetailPo.setAcctId(paramObj.getString("acctId"));
+                        accountDetailPo.setDetailType("2002"); //1001 转入 2002 转出
+                        accountDetailPo.setRelAcctId("-1");
+                        accountDetailPo.setAmount(redepositAmount.toString());
+                        accountDetailPo.setObjType("6006"); //6006 个人 7007 商户
+                        accountDetailPo.setObjId(paramObj.getString("objId"));
+                        accountDetailPo.setOrderId("-1");
+                        accountDetailPo.setbId("-1");
+                        accountDetailPo.setRemark("手机端现金账户抵扣");
+                        accountDetailPo.setCreateTime(new Date());
+                        accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo);
+                        //生成抵扣明细记录
+                        FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo();
+                        feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId));
+                        feeAccountDetailPo.setDetailId(accountDetailPo.getDetailId());
+                        feeAccountDetailPo.setCommunityId(paramIn.getString("communityId"));
+                        feeAccountDetailPo.setState("1002"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣
+                        feeAccountDetailPo.setAmount(redepositAmount.toString()); //积分抵扣金额
+                        feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo);
+                    }
+                }
+            }
             param.put("code", "100");
             param.put("msg", "扣费为0回调成功");
             return new ResponseEntity(JSONObject.toJSONString(param), HttpStatus.OK);

+ 0 - 2
service-fee/src/main/java/com/java110/fee/api/FeePrintSpecApi.java

@@ -44,7 +44,6 @@ public class FeePrintSpecApi {
     public ResponseEntity<String> saveFeePrintSpec(@RequestBody JSONObject reqJson) {
 
         Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
-        Assert.hasKeyAndValue(reqJson, "content", "请求报文中未包含content");
         Assert.hasKeyAndValue(reqJson, "specCd", "请求报文中未包含specCd");
 
 
@@ -64,7 +63,6 @@ public class FeePrintSpecApi {
     public ResponseEntity<String> updateFeePrintSpec(@RequestBody JSONObject reqJson) {
 
         Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
-        Assert.hasKeyAndValue(reqJson, "content", "请求报文中未包含content");
         Assert.hasKeyAndValue(reqJson, "specCd", "请求报文中未包含specCd");
         Assert.hasKeyAndValue(reqJson, "printId", "printId不能为空");
 

+ 168 - 3
service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java

@@ -16,13 +16,18 @@ import com.java110.dto.fee.FeeAttrDto;
 import com.java110.dto.fee.FeeDetailDto;
 import com.java110.dto.fee.FeeDto;
 import com.java110.dto.feeDiscount.ComputeDiscountDto;
+import com.java110.intf.acct.IAccountDetailInnerServiceSMO;
 import com.java110.intf.acct.IAccountInnerServiceSMO;
 import com.java110.intf.acct.ICouponUserV1InnerServiceSMO;
 import com.java110.intf.community.ICommunityV1InnerServiceSMO;
 import com.java110.intf.community.IRepairUserInnerServiceSMO;
 import com.java110.intf.community.IRoomInnerServiceSMO;
 import com.java110.intf.fee.*;
+import com.java110.intf.feeAccountDetail.IFeeAccountDetailServiceSMO;
 import com.java110.intf.user.IOwnerCarInnerServiceSMO;
+import com.java110.po.account.AccountPo;
+import com.java110.po.accountDetail.AccountDetailPo;
+import com.java110.po.feeAccountDetail.FeeAccountDetailPo;
 import com.java110.utils.cache.CommonCache;
 import com.java110.utils.constant.ResponseConstant;
 import com.java110.utils.exception.CmdException;
@@ -30,6 +35,7 @@ import com.java110.utils.exception.ListenerExecuteException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.StringUtil;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -39,6 +45,7 @@ import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -86,6 +93,7 @@ public class PayFeePreCmd extends AbstractServiceCmdListener {
 
     @Autowired
     private IComputeFeeSMO computeFeeSMOImpl;
+
     @Autowired
     private ICouponUserV1InnerServiceSMO couponUserV1InnerServiceSMOImpl;
 
@@ -95,6 +103,12 @@ public class PayFeePreCmd extends AbstractServiceCmdListener {
     @Autowired
     private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IAccountDetailInnerServiceSMO accountDetailInnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeAccountDetailServiceSMO feeAccountDetailServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.jsonObjectHaveKey(reqJson, "communityId", "请求报文中未包含communityId节点");
@@ -229,12 +243,160 @@ public class PayFeePreCmd extends AbstractServiceCmdListener {
             return 0.0;
         }
 
+        BigDecimal money = new BigDecimal(0);
         BigDecimal totalAccountAmount = new BigDecimal(0);
         for (AccountDto tmpAccountDto : accountDtos) {
-            totalAccountAmount = totalAccountAmount.add(new BigDecimal(tmpAccountDto.getAmount()));
+            if (!StringUtil.isEmpty(tmpAccountDto.getAcctType()) && tmpAccountDto.getAcctType().equals("2004")) { //积分账户
+                //账户金额
+                BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount());
+                //获取最大抵扣积分
+                BigDecimal maximumNumber = new BigDecimal(tmpAccountDto.getMaximumNumber());
+                //获取积分抵扣比例
+                BigDecimal deductionProportion = new BigDecimal(tmpAccountDto.getDeductionProportion());
+                int flag = amount.compareTo(maximumNumber);
+                BigDecimal redepositAmount = new BigDecimal("0.00");
+                BigDecimal integralAmount = new BigDecimal("0.00");
+                if (flag == 1) { //账户积分大于最大使用积分,就用最大使用积分抵扣
+                    redepositAmount = maximumNumber;
+                    integralAmount = amount.subtract(maximumNumber);
+                }
+                if (flag > -1) { //账户积分大于等于最大使用积分,就用最大使用积分抵扣
+                    redepositAmount = maximumNumber;
+                    integralAmount = amount.subtract(maximumNumber);
+                }
+                if (flag == -1) { //账户积分小于最大使用积分,就用账户积分抵扣
+                    redepositAmount = amount;
+                }
+                if (flag < 1) { //账户积分小于等于最大使用积分,就用账户积分抵扣
+                    redepositAmount = amount;
+                }
+                if (flag == 0) { //账户积分等于最大使用积分
+                    redepositAmount = amount;
+                }
+                //更新账户信息
+                AccountPo accountPo = new AccountPo();
+                accountPo.setAcctId(tmpAccountDto.getAcctId());
+                accountPo.setAmount(integralAmount.toString());
+                accountInnerServiceSMOImpl.updateAccount(accountPo);
+                //生成账户详情
+                AccountDetailPo accountDetailPo = new AccountDetailPo();
+                accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
+                accountDetailPo.setAcctId(tmpAccountDto.getAcctId());
+                accountDetailPo.setDetailType("2002"); //1001 转入 2002 转出
+                accountDetailPo.setRelAcctId("-1");
+                accountDetailPo.setAmount(redepositAmount.toString());
+                accountDetailPo.setObjType("6006"); //6006 个人 7007 商户
+                accountDetailPo.setObjId(tmpAccountDto.getObjId());
+                accountDetailPo.setOrderId("-1");
+                accountDetailPo.setbId("-1");
+                accountDetailPo.setRemark("手机端积分抵扣");
+                accountDetailPo.setCreateTime(new Date());
+                accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo);
+                //计算积分换算的金额
+                BigDecimal divide = redepositAmount.divide(deductionProportion);
+                BigDecimal dedAmount = new BigDecimal(deductionAmount);
+                //计算实付金额
+                int flag2 = divide.compareTo(dedAmount);
+                BigDecimal subtract = new BigDecimal("0.00");
+                //生成抵扣明细记录
+                FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo();
+                if (flag2 == -1) { //积分换算金额小于应付金额
+                    subtract = dedAmount.subtract(divide);
+                    BigDecimal multiply = divide.multiply(deductionProportion);
+                    feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额
+                } else if (flag < 1) { //积分换算金额小于等于应付金额
+                    subtract = dedAmount.subtract(divide);
+                    BigDecimal multiply = divide.multiply(deductionProportion);
+                    feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额
+                } else {
+                    BigDecimal multiply = dedAmount.multiply(deductionProportion);
+                    feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额
+                }
+                reqJson.put("receivedMoney", subtract);
+                feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId));
+                feeAccountDetailPo.setDetailId(accountDetailPo.getDetailId());
+                feeAccountDetailPo.setCommunityId(reqJson.getString("communityId"));
+                feeAccountDetailPo.setState("1003"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣
+                feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo);
+                money = subtract;
+            } else if (!StringUtil.isEmpty(tmpAccountDto.getAcctType()) && tmpAccountDto.getAcctType().equals("2003")) { //现金账户
+                //账户金额
+                BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount());
+                //获取应收金额
+                BigDecimal dedAmount = new BigDecimal("0.00");
+                if (reqJson.containsKey("receivedMoney") && !StringUtil.isEmpty(reqJson.getString("receivedMoney"))) {
+                    dedAmount = new BigDecimal(reqJson.getString("receivedMoney"));
+                } else {
+                    dedAmount = new BigDecimal(reqJson.getString("deductionAmount"));
+                }
+                int flag = amount.compareTo(dedAmount);
+                BigDecimal redepositAmount = new BigDecimal("0.00");
+                BigDecimal integralAmount = new BigDecimal("0.00");
+                if (flag == 1) { //现金账户大于应收金额,就用应收金额抵扣
+                    redepositAmount = dedAmount;
+                    integralAmount = amount.subtract(dedAmount);
+                }
+                if (flag > -1) { //现金账户大于等于应收金额,就用应收金额抵扣
+                    redepositAmount = dedAmount;
+                    integralAmount = amount.subtract(dedAmount);
+                }
+                if (flag == -1) { //现金账户小于实收金额,就用现金账户抵扣
+                    redepositAmount = amount;
+                }
+                if (flag < 1) { //现金账户小于等于应收金额,就用现金账户抵扣
+                    redepositAmount = amount;
+                }
+                if (flag == 0) { //现金账户等于应收金额
+                    redepositAmount = amount;
+                }
+                //更新账户信息
+                AccountPo accountPo = new AccountPo();
+                accountPo.setAcctId(tmpAccountDto.getAcctId());
+                accountPo.setAmount(integralAmount.toString());
+                accountInnerServiceSMOImpl.updateAccount(accountPo);
+                //生成账户详情
+                AccountDetailPo accountDetailPo = new AccountDetailPo();
+                accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
+                accountDetailPo.setAcctId(tmpAccountDto.getAcctId());
+                accountDetailPo.setDetailType("2002"); //1001 转入 2002 转出
+                accountDetailPo.setRelAcctId("-1");
+                accountDetailPo.setAmount(redepositAmount.toString());
+                accountDetailPo.setObjType("6006"); //6006 个人 7007 商户
+                accountDetailPo.setObjId(tmpAccountDto.getObjId());
+                accountDetailPo.setOrderId("-1");
+                accountDetailPo.setbId("-1");
+                accountDetailPo.setRemark("手机端现金账户抵扣");
+                accountDetailPo.setCreateTime(new Date());
+                accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo);
+                //生成抵扣明细记录
+                FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo();
+                feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId));
+                feeAccountDetailPo.setDetailId(accountDetailPo.getDetailId());
+                feeAccountDetailPo.setCommunityId(reqJson.getString("communityId"));
+                feeAccountDetailPo.setState("1002"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣
+                feeAccountDetailPo.setAmount(redepositAmount.toString()); //积分抵扣金额
+                feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo);
+                int flag2 = money.compareTo(amount);
+                if (flag2 == 1) { //剩余金额大于现金账户
+                    money = money.subtract(amount);
+                }
+                if (flag > -1) { //剩余金额大于等于现金账户
+                    money = money.subtract(amount);
+                }
+                if (flag == -1) { //剩余金额小于现金账户
+                    money = new BigDecimal(0);
+                }
+                if (flag < 1) { //剩余金额小于等于现金账户
+                    money = new BigDecimal(0);
+                }
+                if (flag == 0) { //剩余金额等于现金账户
+                    money = new BigDecimal(0);
+                }
+            }
+//            totalAccountAmount = totalAccountAmount.add(new BigDecimal(tmpAccountDto.getAmount()));
         }
 
-        double tmpDeductionAmount = totalAccountAmount.subtract(new BigDecimal(deductionAmount)).doubleValue();
+       /* double tmpDeductionAmount = totalAccountAmount.subtract(new BigDecimal(deductionAmount)).doubleValue();
         if (tmpDeductionAmount < 0) {
             reqJson.put("deductionAmount", totalAccountAmount.doubleValue());
             reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos));
@@ -242,7 +404,10 @@ public class PayFeePreCmd extends AbstractServiceCmdListener {
         }
         reqJson.put("deductionAmount", deductionAmount);
         reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos));
-        return deductionAmount;
+        return deductionAmount;*/
+        reqJson.put("deductionAmount", money.doubleValue());
+        reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos));
+        return money.doubleValue();
     }
 
     private double checkCouponUser(JSONObject paramObj) {

+ 7 - 0
service-order/src/main/resources/application-dev.yml

@@ -76,6 +76,13 @@ spring:
     maxActive: 20
     username: TT
 
+  feign:
+    client:
+      config:
+        default:
+          connect-timeout: 30000
+          read-timeout: 30000
+
 #============== kafka ===================
 kafka:
   consumer: