# Conflicts: # mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.javarelease_toaliyun_real
| @@ -2,11 +2,13 @@ package com.iformall.service.test; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.msg.WxMsgRecord; | |||||
| import com.iformall.domain.vo.WxBillAll; | import com.iformall.domain.vo.WxBillAll; | ||||
| import com.iformall.enums.EnumSettleRecordWay; | |||||
| import com.iformall.enums.EnumSettleStatus; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.mapper.WxBillSettleMapper; | import com.iformall.mapper.WxBillSettleMapper; | ||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.Constant; | |||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.shiro.SecurityUtils; | import org.apache.shiro.SecurityUtils; | ||||
| import org.apache.shiro.authc.UsernamePasswordToken; | import org.apache.shiro.authc.UsernamePasswordToken; | ||||
| @@ -32,6 +34,8 @@ import org.springframework.web.context.WebApplicationContext; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| @Slf4j | @Slf4j | ||||
| @AutoConfigureMockMvc | @AutoConfigureMockMvc | ||||
| @@ -62,6 +66,10 @@ public class Test { | |||||
| private MockMvc mockMvc; | private MockMvc mockMvc; | ||||
| @Autowired | |||||
| MqBaseProducer mqBaseProducer; | |||||
| @Autowired | @Autowired | ||||
| private WxBillSettleService wxBillSettleService; | private WxBillSettleService wxBillSettleService; | ||||
| @Autowired | @Autowired | ||||
| @@ -121,6 +129,18 @@ public class Test { | |||||
| wxBillSettleMapper.updateByPrimaryKeySelective(wxBillSettle); | wxBillSettleMapper.updateByPrimaryKeySelective(wxBillSettle); | ||||
| } | } | ||||
| @org.junit.Test | |||||
| public void testmq(){ | |||||
| Map<String,String> dynamicContentMap = new HashMap<>(); | |||||
| dynamicContentMap.put("page", Constant.adminPage); | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.FLOW_ASSIGNEE_NODIFY.getCode()); | |||||
| wxMsgRecord.setReceiver("18601973448"); | |||||
| wxMsgRecord.setTenantId("456"); | |||||
| wxMsgRecord.setDynamicContentMap(dynamicContentMap); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } | |||||
| } | } | ||||
| @@ -9,7 +9,6 @@ import com.iformall.domain.vo.WxBillAll; | |||||
| import com.iformall.enums.EnumMerchantStatus; | import com.iformall.enums.EnumMerchantStatus; | ||||
| import com.iformall.service.WxBillAllService; | import com.iformall.service.WxBillAllService; | ||||
| import com.iformall.service.WxBillSettleService; | import com.iformall.service.WxBillSettleService; | ||||
| import com.iformall.service.WxMerchantBUserService; | |||||
| import com.iformall.service.WxMerchantService; | import com.iformall.service.WxMerchantService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| @@ -19,7 +18,6 @@ import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.mq; | package com.iformall.mq; | ||||
| import com.iformall.domain.po.msg.BaseMsg; | import com.iformall.domain.po.msg.BaseMsg; | ||||
| import org.springframework.amqp.rabbit.core.RabbitTemplate; | |||||
| public interface MqBaseProducer { | public interface MqBaseProducer { | ||||
| @@ -1,7 +1,6 @@ | |||||
| package com.iformall.mq.impl; | package com.iformall.mq.impl; | ||||
| import com.iformall.domain.po.msg.BaseMsg; | import com.iformall.domain.po.msg.BaseMsg; | ||||
| import com.iformall.enums.EnumMsgRecordStatus; | |||||
| import com.iformall.mapper.WxMsgRecordMapper; | import com.iformall.mapper.WxMsgRecordMapper; | ||||
| import com.iformall.mq.MQConfig; | import com.iformall.mq.MQConfig; | ||||
| import com.iformall.mq.MqBaseProducer; | import com.iformall.mq.MqBaseProducer; | ||||
| @@ -10,6 +9,7 @@ import com.iformall.utils.JsonUtil; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.amqp.core.AmqpTemplate; | import org.springframework.amqp.core.AmqpTemplate; | ||||
| import org.springframework.amqp.rabbit.support.CorrelationData; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.annotation.Profile; | import org.springframework.context.annotation.Profile; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -30,6 +30,17 @@ public class RabbitMqMessageProducer implements MqBaseProducer { | |||||
| private WxMsgRecordMapper wxMsgRecordMapper; | private WxMsgRecordMapper wxMsgRecordMapper; | ||||
| @Autowired | @Autowired | ||||
| private WxMsgRecordService wxMsgRecordService; | private WxMsgRecordService wxMsgRecordService; | ||||
| // | |||||
| // @Override | |||||
| // public void confirm(CorrelationData correlationData, boolean b, String s) { | |||||
| // log.info("------correlationData"+correlationData.toString()); | |||||
| // System.out.println(); | |||||
| // if(b){ | |||||
| // System.out.println(); | |||||
| // }else{ | |||||
| // | |||||
| // } | |||||
| // } | |||||
| @Override | @Override | ||||
| public void sendMessage(BaseMsg data, String topic, String tags, String keys) { | public void sendMessage(BaseMsg data, String topic, String tags, String keys) { | ||||
| @@ -37,11 +48,13 @@ public class RabbitMqMessageProducer implements MqBaseProducer { | |||||
| data.setUuid(UUID.randomUUID().toString()); | data.setUuid(UUID.randomUUID().toString()); | ||||
| wxMsgRecordService.save(data); | wxMsgRecordService.save(data); | ||||
| //CorrelationData correlationData = new CorrelationData("16746324"); | |||||
| rabbitTemplate.convertAndSend(topic, JsonUtil.obj2Json(data)); | rabbitTemplate.convertAndSend(topic, JsonUtil.obj2Json(data)); | ||||
| // data.setMsgStatus(EnumMsgRecordStatus.SEND_SUCC.getCode()); | // data.setMsgStatus(EnumMsgRecordStatus.SEND_SUCC.getCode()); | ||||
| // wxMsgRecordMapper.update(data); | // wxMsgRecordMapper.update(data); | ||||
| log.info(data.getUuid()+"发送mq成功。"); | log.info(data.getUuid()+"发送mq成功。"); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| log.error("RabbitMqMessageProducer: Send Message Error ", e); | log.error("RabbitMqMessageProducer: Send Message Error ", e); | ||||
| } | } | ||||
| @@ -14,6 +14,7 @@ import org.apache.rocketmq.common.message.Message; | |||||
| import org.apache.rocketmq.remoting.common.RemotingHelper; | import org.apache.rocketmq.remoting.common.RemotingHelper; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.amqp.rabbit.support.CorrelationData; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.context.annotation.Profile; | import org.springframework.context.annotation.Profile; | ||||
| @@ -42,6 +43,11 @@ public class RocketMqMessageProducer implements MqBaseProducer { | |||||
| @Autowired | @Autowired | ||||
| private WxMsgRecordService wxMsgRecordService; | private WxMsgRecordService wxMsgRecordService; | ||||
| // @Override | |||||
| // public void confirm(CorrelationData correlationData, boolean b, String s) { | |||||
| // | |||||
| // } | |||||
| @PostConstruct | @PostConstruct | ||||
| public void start(){ | public void start(){ | ||||
| try { | try { | ||||
| @@ -1184,7 +1184,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||||
| Date date = new Date(); | Date date = new Date(); | ||||
| daily.setCreatetime(date); | daily.setCreatetime(date); | ||||
| daily.setUpdatetime(date); | daily.setUpdatetime(date); | ||||
| daily.setOwe(receivePay); | |||||
| daily.setOwe(receivePay - pay); | |||||
| daily.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | daily.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| daily.setStarttime(bill.getStarttime()); | daily.setStarttime(bill.getStarttime()); | ||||
| daily.setEndtime(bill.getEndtime()); | daily.setEndtime(bill.getEndtime()); | ||||
| @@ -1249,7 +1249,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||||
| Date date = new Date(); | Date date = new Date(); | ||||
| other.setCreatetime(date); | other.setCreatetime(date); | ||||
| other.setUpdatetime(date); | other.setUpdatetime(date); | ||||
| other.setOwe(receivePay); | |||||
| other.setOwe(receivePay - pay); | |||||
| other.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | other.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| other.setStarttime(bill.getStarttime()); | other.setStarttime(bill.getStarttime()); | ||||
| other.setEndtime(bill.getEndtime()); | other.setEndtime(bill.getEndtime()); | ||||
| @@ -1316,7 +1316,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||||
| otherDeposit.setCreatetime(date); | otherDeposit.setCreatetime(date); | ||||
| otherDeposit.setUpdatetime(date); | otherDeposit.setUpdatetime(date); | ||||
| otherDeposit.setExpiredDay(0L); | otherDeposit.setExpiredDay(0L); | ||||
| otherDeposit.setOwe(receivePay); | |||||
| otherDeposit.setOwe(receivePay - pay); | |||||
| otherDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | otherDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| otherDeposit.setStarttime(bill.getStarttime()); | otherDeposit.setStarttime(bill.getStarttime()); | ||||
| otherDeposit.setEndtime(bill.getEndtime()); | otherDeposit.setEndtime(bill.getEndtime()); | ||||
| @@ -4,10 +4,9 @@ import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.enums.EnumBusinessConType; | |||||
| import com.iformall.enums.EnumBusinessFilter; | import com.iformall.enums.EnumBusinessFilter; | ||||
| import com.iformall.enums.EnumIsPreview; | import com.iformall.enums.EnumIsPreview; | ||||
| import com.iformall.enums.EnumRentContractType; | |||||
| import com.iformall.enums.EnumRentContractStatus; | |||||
| import com.iformall.mapper.WxBusinessMapper; | import com.iformall.mapper.WxBusinessMapper; | ||||
| import com.iformall.mapper.WxPropertyContractMapper; | import com.iformall.mapper.WxPropertyContractMapper; | ||||
| import com.iformall.mapper.WxRentContractMapper; | import com.iformall.mapper.WxRentContractMapper; | ||||
| @@ -20,9 +19,11 @@ import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | |||||
| import java.util.*; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @Service | @Service | ||||
| public class WxBusinessServiceImpl implements WxBusinessService { | public class WxBusinessServiceImpl implements WxBusinessService { | ||||
| @@ -80,9 +81,10 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||||
| query.setBusinessId((Integer) e.get("id")); | query.setBusinessId((Integer) e.get("id")); | ||||
| List<WxRentContract> rentContractList = wxRentContractMapper.select(query); | List<WxRentContract> rentContractList = wxRentContractMapper.select(query); | ||||
| for (WxRentContract dbRent:rentContractList ) { | for (WxRentContract dbRent:rentContractList ) { | ||||
| logger.info("业态分析租赁合同:{}"+dbRent.getId()); | |||||
| logger.error("业态分析租赁合同:{}"+dbRent.getId()); | |||||
| if(StringUtils.isBlank(dbRent.getRentInfo())){ | |||||
| if (StringUtils.isBlank(dbRent.getRentInfo()) || | |||||
| dbRent.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) || | |||||
| dbRent.getStatus().equals(EnumRentContractStatus.RENT_PAID.getCode()) || | |||||
| dbRent.getStatus().equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())) { | |||||
| System.out.println("rent rentInfo is null:{}"+dbRent.getId()); | System.out.println("rent rentInfo is null:{}"+dbRent.getId()); | ||||
| continue; | continue; | ||||
| } | } | ||||
| @@ -101,9 +103,10 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||||
| pquery.setBusinessId((Integer) e.get("id")); | pquery.setBusinessId((Integer) e.get("id")); | ||||
| List<WxPropertyContract> propertyContractList = wxPropertyContractMapper.select(pquery); | List<WxPropertyContract> propertyContractList = wxPropertyContractMapper.select(pquery); | ||||
| for (WxPropertyContract dbRent:propertyContractList) { | for (WxPropertyContract dbRent:propertyContractList) { | ||||
| logger.info("业态分析物业合同:{}"+dbRent.getId()); | |||||
| logger.error("业态分析物业合同:{}"+dbRent.getId()); | |||||
| if(StringUtils.isBlank(dbRent.getRentInfo())){ | |||||
| if (StringUtils.isBlank(dbRent.getRentInfo()) || | |||||
| dbRent.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) || | |||||
| dbRent.getStatus().equals(EnumRentContractStatus.RENT_PAID.getCode()) || | |||||
| dbRent.getStatus().equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())) { | |||||
| System.out.println("property rentInfo is null:{}"+dbRent.getId()); | System.out.println("property rentInfo is null:{}"+dbRent.getId()); | ||||
| continue; | continue; | ||||
| } | } | ||||
| @@ -311,8 +311,8 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| wxBillSettleService.updateFreezeOrStatus(settle.getPayBillIds(),EnumFreezeType.DEF.getCode(),EnumBillRentStatus.PAID.getCode()); | wxBillSettleService.updateFreezeOrStatus(settle.getPayBillIds(),EnumFreezeType.DEF.getCode(),EnumBillRentStatus.PAID.getCode()); | ||||
| }else if(EnumRentContractAppStatus.SETBACK.getCode().intValue() == applyStatus.intValue() || EnumRentContractAppStatus.REJECT.getCode().intValue() == applyStatus.intValue()) { | }else if(EnumRentContractAppStatus.SETBACK.getCode().intValue() == applyStatus.intValue() || EnumRentContractAppStatus.REJECT.getCode().intValue() == applyStatus.intValue()) { | ||||
| //解冻 | //解冻 | ||||
| wxBillSettleService.updateFreezeOrStatus(settle.getReceiveBillIds(), EnumFreezeType.DEF.getCode(),EnumBillRentStatus.PAID.getCode()); | |||||
| wxBillSettleService.updateFreezeOrStatus(settle.getPayBillIds(),EnumFreezeType.DEF.getCode(),EnumBillRentStatus.PAID.getCode()); | |||||
| wxBillSettleService.updateFreezeOrStatus(settle.getReceiveBillIds(), EnumFreezeType.DEF.getCode(),null); | |||||
| wxBillSettleService.updateFreezeOrStatus(settle.getPayBillIds(),EnumFreezeType.DEF.getCode(),null); | |||||
| } | } | ||||
| wxBillSettleMapper.updateByPrimaryKeySelective(wxBillSettle); | wxBillSettleMapper.updateByPrimaryKeySelective(wxBillSettle); | ||||
| } | } | ||||
| @@ -117,8 +117,9 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||||
| receiver.setMerchantId(merchant.getId()); | receiver.setMerchantId(merchant.getId()); | ||||
| receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode()); | receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode()); | ||||
| receiver.setId(IdWorker.get().nextId()); | receiver.setId(IdWorker.get().nextId()); | ||||
| receiver.setCreateTime(new Date()); | |||||
| receiver.setUpdateTime(new Date()); | |||||
| Date date = new Date(); | |||||
| receiver.setCreateTime(date); | |||||
| receiver.setUpdateTime(date); | |||||
| receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); | receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); | ||||
| receiver.setIsUse(EnumProfitSharingUse.APPLY.getCode()); | receiver.setIsUse(EnumProfitSharingUse.APPLY.getCode()); | ||||
| //passed from uplevel | //passed from uplevel | ||||
| @@ -258,61 +259,75 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||||
| if (receiver == null) | if (receiver == null) | ||||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage()); | return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage()); | ||||
| //删除分账账户从微信服务器 | |||||
| WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); | |||||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||||
| wxProfitSharingReceiverP.setSign_type("HMAC-SHA256"); | |||||
| JSONObject receiverJSON = new JSONObject(); | |||||
| receiverJSON.put("type", EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||||
| receiverJSON.put("account", receiver.getReceiverAccount()); | |||||
| wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); | |||||
| String response; | |||||
| try { | |||||
| wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||||
| response = WxProfitSharing.delReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); | |||||
| } catch (Exception e) { | |||||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + e.getMessage()); | |||||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED, e.getMessage()); | |||||
| } | |||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||||
| String return_code = returnMap.get("return_code"); | |||||
| if (!"SUCCESS".equals(return_code)) { | |||||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("return_msg")); | |||||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("return_msg")); | |||||
| } | |||||
| //检查此接受者是否注册在同一个商场的别的商户下 | |||||
| final WxProfitSharingReceiver receiverParam = receiver; | |||||
| WxProfitSharingReceiver params = new WxProfitSharingReceiver(); | |||||
| params.setTenantId(receiver.getTenantId()); | |||||
| params.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); | |||||
| List<WxProfitSharingReceiver> receiverList = wxProfitSharingReceiverMapper.findList(params); | |||||
| if (receiverList.stream().anyMatch(r -> ( | |||||
| r.getReceiverType().equals(receiverParam.getReceiverType()) && | |||||
| r.getReceiverAccount().equals(receiverParam.getReceiverAccount()) && | |||||
| r.getTrueName().equals(receiverParam.getTrueName()) && | |||||
| !r.getMerchantId().equals(receiverParam.getMerchantId()) | |||||
| ))) { | |||||
| //还有别的商户使用这个账号,不从微信服务器申请删除 | |||||
| } else { | |||||
| //删除分账账户从微信服务器 | |||||
| WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); | |||||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||||
| wxProfitSharingReceiverP.setSign_type("HMAC-SHA256"); | |||||
| JSONObject receiverJSON = new JSONObject(); | |||||
| receiverJSON.put("type", EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||||
| receiverJSON.put("account", receiver.getReceiverAccount()); | |||||
| wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); | |||||
| String response; | |||||
| try { | |||||
| wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||||
| response = WxProfitSharing.delReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); | |||||
| } catch (Exception e) { | |||||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + e.getMessage()); | |||||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED, e.getMessage()); | |||||
| } | |||||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||||
| String return_code = returnMap.get("return_code"); | |||||
| if (!"SUCCESS".equals(return_code)) { | |||||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("return_msg")); | |||||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("return_msg")); | |||||
| } | |||||
| String result_code = returnMap.get("result_code"); | |||||
| if (!"SUCCESS".equals(result_code)) { | |||||
| String result_code = returnMap.get("result_code"); | |||||
| if (!"SUCCESS".equals(result_code)) { | |||||
| if (returnMap.get("err_code").contains("USER_NOT_EXIST")) { | |||||
| receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode()); | |||||
| receiver.setUpdateTime(new Date()); | |||||
| wxProfitSharingReceiverMapper.updateByPrimaryKeySelective(receiver); | |||||
| if (returnMap.get("err_code").contains("USER_NOT_EXIST")) { | |||||
| receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode()); | |||||
| receiver.setUpdateTime(new Date()); | |||||
| wxProfitSharingReceiverMapper.updateByPrimaryKeySelective(receiver); | |||||
| } | |||||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("err_code_des")); | |||||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("err_code_des")); | |||||
| } | } | ||||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("err_code_des")); | |||||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("err_code_des")); | |||||
| } | |||||
| if (!WxPayment.verifyNotifyHMAC(returnMap, payAccount.getApiKey())) { | |||||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage()); | |||||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), "verifyNotifyHMAC"); | |||||
| } | |||||
| if (!WxPayment.verifyNotifyHMAC(returnMap, payAccount.getApiKey())) { | |||||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage()); | |||||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), "verifyNotifyHMAC"); | |||||
| } | |||||
| receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode()); | |||||
| receiver.setUpdateTime(new Date()); | |||||
| wxProfitSharingReceiverMapper.updateByPrimaryKeySelective(receiver); | |||||
| receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode()); | |||||
| receiver.setUpdateTime(new Date()); | |||||
| wxProfitSharingReceiverMapper.updateByPrimaryKeySelective(receiver); | |||||
| //发送短信 | |||||
| if (send.equals(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode())) { | |||||
| sendMsgByType(EnumMsgModel.DELETE_SHARING_ACCOUNT_NOTIFY_MERCHANT.getCode(), receiver.getMerchantId(), receiver.getReceiverAccount(), receiver.getTenantId()); | |||||
| //发送短信 | |||||
| if (send.equals(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode())) { | |||||
| sendMsgByType(EnumMsgModel.DELETE_SHARING_ACCOUNT_NOTIFY_MERCHANT.getCode(), receiver.getMerchantId(), receiver.getReceiverAccount(), receiver.getTenantId()); | |||||
| } | |||||
| } | } | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -283,7 +283,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| ratioVo.setUseRatio("["); | ratioVo.setUseRatio("["); | ||||
| for (int i = 0; i < ratioList.size(); i++) { | for (int i = 0; i < ratioList.size(); i++) { | ||||
| BigDecimal revenue = new BigDecimal(revenueLong).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); | |||||
| BigDecimal revenue = new BigDecimal(revenueLong).divide(new BigDecimal(1000000)).setScale(8, RoundingMode.HALF_EVEN); | |||||
| String e = ratioList.get(i); | String e = ratioList.get(i); | ||||
| String[] array = e.split(":"); | String[] array = e.split(":"); | ||||
| Integer ratio = Integer.parseInt(array[1]); | Integer ratio = Integer.parseInt(array[1]); | ||||
| @@ -316,7 +316,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| if (revenue.compareTo(start) >= 0 && revenue.compareTo(end)<= 0){ | if (revenue.compareTo(start) >= 0 && revenue.compareTo(end)<= 0){ | ||||
| ratioVo.setRatio(ratio); | ratioVo.setRatio(ratio); | ||||
| ratioVo.setPrice(countPrice(ratioVo.getRatio(),revenueLong,timeType,period,from)); | ratioVo.setPrice(countPrice(ratioVo.getRatio(),revenueLong,timeType,period,from)); | ||||
| ratioVo.setUseRatio(ratioVo.getUseRatio()+e+","); | |||||
| ratioVo.setUseRatio(ratioVo.getUseRatio()+"\""+e+"\","); | |||||
| break; | break; | ||||
| } | } | ||||
| }else if(e.indexOf(">") >= 0){ | }else if(e.indexOf(">") >= 0){ | ||||
| @@ -343,7 +343,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| if (revenue.compareTo(end) >= 0){ | if (revenue.compareTo(end) >= 0){ | ||||
| ratioVo.setRatio(ratio); | ratioVo.setRatio(ratio); | ||||
| ratioVo.setUseRatio(ratioVo.getUseRatio()+e+","); | |||||
| ratioVo.setUseRatio(ratioVo.getUseRatio()+"\""+e+"\","); | |||||
| //计算超出部分 | //计算超出部分 | ||||
| BigDecimal payRatio = new BigDecimal(ratio).divide(new BigDecimal(10000)); | BigDecimal payRatio = new BigDecimal(ratio).divide(new BigDecimal(10000)); | ||||
| @@ -354,12 +354,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| Integer frontatio = Integer.parseInt(array[1]); | Integer frontatio = Integer.parseInt(array[1]); | ||||
| revenueArray = array[0].split("-"); | revenueArray = array[0].split("-"); | ||||
| BigDecimal frontEnd = new BigDecimal(0); | |||||
| BigDecimal frontEnd; | |||||
| if(EnumGetRatioFrom.BILL.getCode().equals(from)){ | if(EnumGetRatioFrom.BILL.getCode().equals(from)){ | ||||
| if(EnumMissTimeType.YEAR.getCode().equals(timeType)){ | if(EnumMissTimeType.YEAR.getCode().equals(timeType)){ | ||||
| frontEnd = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365), 10, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); | frontEnd = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365), 10, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); | ||||
| }else if(EnumMissTimeType.MONTH.getCode().equals(timeType)){ | }else if(EnumMissTimeType.MONTH.getCode().equals(timeType)){ | ||||
| frontEnd = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30), 10, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); | frontEnd = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30), 10, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); | ||||
| }else{ | |||||
| frontEnd = new BigDecimal(revenueArray[1]); | |||||
| } | } | ||||
| }else{ | }else{ | ||||
| frontEnd = new BigDecimal(revenueArray[1]); | frontEnd = new BigDecimal(revenueArray[1]); | ||||
| @@ -367,8 +367,6 @@ | |||||
| ) bill | ) bill | ||||
| on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=1 | on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=1 | ||||
| ) | ) | ||||
| - | |||||
| (select IFNULL(sum(settle_money),0) from wx_bill_settle_record where settle_id = s.id) | |||||
| ) receive_pay | ) receive_pay | ||||
| ,0 pay,0 owe,s.createtime receive_date,'' pay_date,0 expired_day,status,'' starttime,'' endtime,'' rent_shop_type,'' price_detail, 0 freeze | ,0 pay,0 owe,s.createtime receive_date,'' pay_date,0 expired_day,status,'' starttime,'' endtime,'' rent_shop_type,'' price_detail, 0 freeze | ||||
| from wx_bill_settle s where s.tenant_id=#{tenantId} and s.status >0 | from wx_bill_settle s where s.tenant_id=#{tenantId} and s.status >0 | ||||
| @@ -733,7 +731,6 @@ | |||||
| select tt.* from ( | select tt.* from ( | ||||
| select m.tenant_id,m.id,m.name,ws.shop_number shopNumber,ws.type,m.link_person linkPerson,m.link_phone linkPhone, | select m.tenant_id,m.id,m.name,ws.shop_number shopNumber,ws.type,m.link_person linkPerson,m.link_phone linkPhone, | ||||
| xb.title business,rc.rental_start_date rentalStartDate,rc.rental_end_date rentalEndDate,rc.rent_shop_type, | xb.title business,rc.rental_start_date rentalStartDate,rc.rental_end_date rentalEndDate,rc.rent_shop_type, | ||||
| round( | round( | ||||
| (select sum(bill.receive_pay) from ( | (select sum(bill.receive_pay) from ( | ||||
| select merchant_id,receive_pay from wx_bill_rent where is_preview = 0 and status not in(3,6) | select merchant_id,receive_pay from wx_bill_rent where is_preview = 0 and status not in(3,6) | ||||
| @@ -805,10 +802,14 @@ | |||||
| select receive_pay money,merchant_id id from wx_bill_other_deposit where status = 3 | select receive_pay money,merchant_id id from wx_bill_other_deposit where status = 3 | ||||
| )ss where ss.id = m.id | )ss where ss.id = m.id | ||||
| )/100,2)) balance | )/100,2)) balance | ||||
| from wx_merchant m left join wx_merchant_shop wms on wms.merchant_id = m.id left join wx_shop ws on wms.shop_id = ws.id | |||||
| from wx_merchant m | |||||
| left join (select ms.merchant_id,s.type,GROUP_CONCAT(s.shop_number) as shop_number | |||||
| from wx_merchant_shop ms inner join wx_shop s on ms.shop_id=s.id where ms.is_del=0 | |||||
| group by ms.merchant_id) ws on m.id=ws.merchant_id | |||||
| left join wx_business xb on(m.business_id = xb.id) | left join wx_business xb on(m.business_id = xb.id) | ||||
| left join wx_rent_contract rc on(rc.merchant_id = m.id) | left join wx_rent_contract rc on(rc.merchant_id = m.id) | ||||
| where m.status=1 | |||||
| ) tt where tt.receivePay >0 and tt.payOut>0 | ) tt where tt.receivePay >0 and tt.payOut>0 | ||||
| <if test=" null != tenantId"> and tt.tenant_id = #{tenantId} </if> | <if test=" null != tenantId"> and tt.tenant_id = #{tenantId} </if> | ||||
| @@ -825,21 +826,22 @@ | |||||
| from ( | from ( | ||||
| select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金' | select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金' | ||||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' | bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' | ||||
| endtime,rent_shop_type,shop_info,NULL comments,'' price_detail,updatetime from wx_bill_rent_deposit where | |||||
| endtime,rent_shop_type,shop_info,NULL comments,'' price_detail,updatetime,freeze from wx_bill_rent_deposit where | |||||
| tenant_id=#{tenantId} | tenant_id=#{tenantId} | ||||
| union all | union all | ||||
| select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金' | select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金' | ||||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' | bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' | ||||
| endtime,rent_shop_type,shop_info,NULL comments,'' price_detail,updatetime from wx_bill_property_deposit where | |||||
| endtime,rent_shop_type,shop_info,NULL comments,'' price_detail,updatetime,freeze from wx_bill_property_deposit where | |||||
| tenant_id=#{tenantId} | tenant_id=#{tenantId} | ||||
| union all | union all | ||||
| select id,merchant_id,shop_id,tenant_id,comments as name,8 bill_type_value,concat('其他押金-',comments) as | select id,merchant_id,shop_id,tenant_id,comments as name,8 bill_type_value,concat('其他押金-',comments) as | ||||
| bill_type,0 as | bill_type,0 as | ||||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime, | need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime, | ||||
| rent_shop_type,'[]' shop_info,comments,'' price_detail,updatetime | |||||
| rent_shop_type,'[]' shop_info,comments,'' price_detail,updatetime,freeze | |||||
| from wx_bill_other_deposit where tenant_id=#{tenantId} | from wx_bill_other_deposit where tenant_id=#{tenantId} | ||||
| ) bill | ) bill | ||||
| where 1=1 | where 1=1 | ||||
| <if test=" null != freeze"> and bill.freeze = #{freeze} </if> | |||||
| <if test=" null != status"> and bill.status = #{status} </if> | <if test=" null != status"> and bill.status = #{status} </if> | ||||
| <if test=" null != merchantId">and bill.merchant_id=#{merchantId}</if> | <if test=" null != merchantId">and bill.merchant_id=#{merchantId}</if> | ||||
| </select> | </select> | ||||