|
@@ -12,7 +12,6 @@ import com.wechat.common.entity.sepAccount.Receivers;
|
|
|
import com.wechat.common.entity.sepAccount.help.SepReceiverHelp;
|
|
|
import com.wechat.common.entity.sepAccount.help.SepUserHandleHelp;
|
|
|
import com.wechat.common.entity.sepAccount.help.UserSepReceiver;
|
|
|
-import com.wechat.common.enums.RegisterStatus;
|
|
|
import com.wechat.common.enums.SepAccountEnums;
|
|
|
import com.wechat.common.parameter.ProjectConstant;
|
|
|
import com.wechat.common.response.RespWrapper;
|
|
@@ -308,8 +307,15 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
|
|
|
@Override
|
|
|
public RespWrapper<String> sepAccountHandle(SepUserHandleHelp handleHelp) {
|
|
|
// 1、校验该商户是否已经添加分账功能
|
|
|
- RespWrapper<Boolean> checkSepFun = checkSepFunction(handleHelp.getSubMchId());
|
|
|
- if(!checkSepFun.isSuccess()) return RespWrapper.makeFailResp(checkSepFun.getMsg());
|
|
|
+ //RespWrapper<Boolean> checkSepFun = checkSepFunction(handleHelp.getSubMchId());
|
|
|
+ //if(!checkSepFun.isSuccess()) return RespWrapper.makeFailResp(checkSepFun.getMsg());
|
|
|
+ KtjMerchantDetails ktj = new KtjMerchantDetails();
|
|
|
+ ktj.setSubMchid(handleHelp.getSubMchId());
|
|
|
+ ktj = merchantDetailsDao.templateOne(ktj);
|
|
|
+ if(null == ktj || ktj.getRegisterStatus() == null) return RespWrapper.makeFailResp("该商户还没有入驻,请先入驻");
|
|
|
+ if(ktj.getRegisterStatus() == 1) return RespWrapper.makeFailResp("该商户审核中,不能进行分账人设置");
|
|
|
+ if(ktj.getRegisterStatus() == 3) return RespWrapper.makeFailResp("该商户入驻失败,请重新入驻");
|
|
|
+
|
|
|
List<KtjSepUser> userList = doFindSepUserList(handleHelp);
|
|
|
if(userList.isEmpty()) return RespWrapper.makeFailResp("请检查是否设置了分账人");
|
|
|
// 查询是否有该笔订单
|
|
@@ -341,7 +347,8 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
|
|
|
boolean isOne = true;
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
int amount = 0;
|
|
|
- for(KtjSepUser user:userList){
|
|
|
+ //存储分账用户信息
|
|
|
+ for(KtjSepUser user : userList){
|
|
|
Float aFloat = Float.valueOf(user.getSepRate());
|
|
|
int tmpAmount = (int) (aFloat.floatValue()*totalFee);
|
|
|
KtjSepUserRecord rd = new KtjSepUserRecord();
|
|
@@ -350,7 +357,6 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
|
|
|
rd.setCreateTime(startTime);
|
|
|
rd.setWxAccount(user.getAccount());
|
|
|
rd.setAmount(tmpAmount);
|
|
|
- rd.setWxAccount(user.getAccount());
|
|
|
addUserList.add(rd);
|
|
|
amount += tmpAmount;
|
|
|
if(tmpAmount > 0){
|
|
@@ -361,6 +367,16 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
|
|
|
sb.append(desc);
|
|
|
}
|
|
|
}
|
|
|
+ if(!addUserList.isEmpty()){
|
|
|
+ //存储商户分账信息
|
|
|
+ KtjSepUserRecord rd = new KtjSepUserRecord();
|
|
|
+ rd.setNickName(ktj.getMerchantName());
|
|
|
+ rd.setGroupName(addUserList.get(0).getGroupName());
|
|
|
+ rd.setCreateTime(startTime);
|
|
|
+ rd.setWxAccount(ktj.getSubMchid());
|
|
|
+ rd.setAmount(Integer.parseInt((totalFee - amount) + ""));
|
|
|
+ addUserList.add(rd);
|
|
|
+ }
|
|
|
//查询特邀商户appid
|
|
|
KtjMerchantDetails merchant = new KtjMerchantDetails();
|
|
|
merchant.setSubMchid(handleHelp.getSubMchId());
|
|
@@ -370,7 +386,7 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
|
|
|
record.setOutOrderNo(outOrderNo);
|
|
|
record.setCreateTime(startTime);
|
|
|
record.setStatus("PROCESSING");//如果发起分账请求成功,则设置成微信处理中
|
|
|
- record.setAmount(amount);//分账
|
|
|
+ record.setAmount(Integer.parseInt(totalFee + ""));//分账
|
|
|
record.setSubMchId(handleHelp.getSubMchId());
|
|
|
record.setTransactionId(handleHelp.getTransactionId());
|
|
|
record.setSep(false);
|
|
@@ -506,9 +522,28 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
|
|
|
//存储分账人记录
|
|
|
KtjReceiversUser kru = null;
|
|
|
List<KtjReceiversUser> listKtjReceiversUser = new ArrayList<KtjReceiversUser>();
|
|
|
+ //查询所以分账人的名称
|
|
|
for (Receivers receivers2 : listReceivers) {
|
|
|
+ KtjMerchantDetails ktj = null;
|
|
|
+ KtjSepUser ksu = null;
|
|
|
+ String name = "";
|
|
|
+ //这是商户类型
|
|
|
+ if("MERCHANT_ID".equals(receivers2.getType())){
|
|
|
+ ktj = new KtjMerchantDetails();
|
|
|
+ ktj.setSubMchid(s.getSubMchId());
|
|
|
+ ktj = merchantDetailsDao.templateOne(ktj);
|
|
|
+ name = null != ktj ? ktj.getMerchantName() : "";
|
|
|
+ }else{
|
|
|
+ ksu = new KtjSepUser();
|
|
|
+ ksu.setAccount(receivers2.getAccount());
|
|
|
+ ksu.setSubMchId(s.getSubMchId());
|
|
|
+ ksu = sepUserDao.templateOne(ksu);
|
|
|
+ name = null != ksu ? ksu.getName() : "";
|
|
|
+ }
|
|
|
kru = new KtjReceiversUser();
|
|
|
updateTime(receivers2,record1.getId(),kru);
|
|
|
+ kru.setName(name);
|
|
|
+ kru.setSubMchid(s.getSubMchId());
|
|
|
listKtjReceiversUser.add(kru);
|
|
|
}
|
|
|
if(!listKtjReceiversUser.isEmpty()){
|
|
@@ -527,6 +562,7 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
|
|
|
kru.setFinishTime(SimpleDateFormatReceiversTime(receivers2.getFinish_time()));
|
|
|
kru.setUserType(receivers2.getType());
|
|
|
kru.setReceiversResult(receivers2.getResult());
|
|
|
+ kru.setAmount(receivers2.getAmount());
|
|
|
kru.setUserAccount(receivers2.getAccount());
|
|
|
}
|
|
|
|