| @@ -7,9 +7,13 @@ import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxBillRent; | |||
| import com.iformall.domain.po.WxPayAccountBill; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.enums.EnumRentShopType; | |||
| import com.iformall.enums.EnumShopType; | |||
| import com.iformall.service.WxBillRentService; | |||
| import com.iformall.service.WxPayAccountBillService; | |||
| import com.iformall.service.WxRentContractService; | |||
| import com.iformall.service.WxShopService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -35,9 +39,10 @@ public class WxRentContractController extends BaseController { | |||
| private WxRentContractService wxRentContractService; | |||
| @Autowired | |||
| private WxBillRentService wxBillRentService; | |||
| @Autowired | |||
| private WxPayAccountBillService payAccountBillService; | |||
| @Autowired | |||
| private WxShopService wxShopService; | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @@ -59,7 +64,11 @@ public class WxRentContractController extends BaseController { | |||
| public ResultData add(@RequestBody WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::add"); | |||
| wxRentContract.setTenantId(getTenantId()); | |||
| if(wxRentContract.getMonthHandleType() != null){ | |||
| //目前只有多经点位租赁合同 | |||
| WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); | |||
| if(wxRentContract.getMonthHandleType() != null && wxRentContract.getMonthHandleType().intValue()==3 | |||
| && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ | |||
| wxRentContract.setAdjustPeriod(wxRentContract.getMonthHandleType()); | |||
| } | |||
| return wxRentContractService.save(wxRentContract, getUser().getId(),getUser().getName()); | |||
| @@ -70,6 +79,12 @@ public class WxRentContractController extends BaseController { | |||
| public ResultData update(@RequestBody WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::update"); | |||
| wxRentContract.setTenantId(getTenantId()); | |||
| //目前只有多经点位租赁合同 | |||
| WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); | |||
| if(wxRentContract.getMonthHandleType() != null && wxRentContract.getMonthHandleType().intValue()==3 | |||
| && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ | |||
| wxRentContract.setAdjustPeriod(wxRentContract.getMonthHandleType()); | |||
| } | |||
| return wxRentContractService.update(wxRentContract, getUser().getId(),getUser().getName()); | |||
| } | |||
| @@ -78,6 +93,12 @@ public class WxRentContractController extends BaseController { | |||
| public ResultData updateMoney(@RequestBody WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::updateMoney"); | |||
| wxRentContract.setTenantId(getTenantId()); | |||
| //目前只有多经点位租赁合同 | |||
| WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); | |||
| if(wxRentContract.getMonthHandleType() != null && wxRentContract.getMonthHandleType().intValue()==3 | |||
| && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ | |||
| wxRentContract.setAdjustPeriod(wxRentContract.getMonthHandleType()); | |||
| } | |||
| return wxRentContractService.update(wxRentContract, getUser().getId(),getUser().getName()); | |||
| } | |||
| @@ -86,6 +107,12 @@ public class WxRentContractController extends BaseController { | |||
| public ResultData updateFile(@RequestBody WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::updateFile"); | |||
| wxRentContract.setTenantId(getTenantId()); | |||
| //目前只有多经点位租赁合同 | |||
| WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); | |||
| if(wxRentContract.getMonthHandleType() != null && wxRentContract.getMonthHandleType().intValue()==3 | |||
| && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ | |||
| wxRentContract.setAdjustPeriod(wxRentContract.getMonthHandleType()); | |||
| } | |||
| return wxRentContractService.updateFile(wxRentContract, getUser().getId(),getUser().getName()); | |||
| } | |||
| @@ -240,6 +240,7 @@ public enum ErrorCode{ | |||
| */ | |||
| VERIFY_ERROR(12050, "核销异常"), | |||
| MSG_REPEAT_SEND(12061, "短信重复发送"), | |||
| VERIFY_COUPON_ORDER_MERANT_IS_NULL(12062, "卡券核销商户无权限"), | |||
| /** | |||
| * 解单 | |||
| @@ -57,4 +57,6 @@ public interface WxRentContractMapper extends CommonMapper<WxRentContract, Long> | |||
| int hasContractNumber(WxRentContract wxRentContract); | |||
| Integer getShopType(WxRentContract wxRentContract); | |||
| } | |||
| @@ -83,4 +83,5 @@ public interface WxRentContractService { | |||
| ResultData hasContractNumber(WxRentContract wxRentContract); | |||
| Integer getShopType(WxRentContract wxRentContract); | |||
| } | |||
| @@ -137,13 +137,15 @@ public class PushLimitServiceImpl implements PushLimitService { | |||
| throw new MallinkException(ErrorCode.PUSH_LIMIT_UP_TO_1DAYLIMIT.getCode(), errMsg); | |||
| } | |||
| // 4. check 每人多少天内不会重复收到一张券 | |||
| params.put("couponId", couponId); | |||
| params.put("dayNum", pushLimit.getCouponDay()-1); | |||
| int countForUserCoupon = wxCouponActionLogMapper.getCountByUserAndCoupon(params); | |||
| if (countForUserCoupon >= 1) { | |||
| String errMsg = "每人" + pushLimit.getCouponDay() + "天领一张券已到疲劳度上限"; | |||
| logger.error(errMsg); | |||
| throw new MallinkException(ErrorCode.PUSH_LIMIT_UP_TO_COUPONLIMIT.getCode(), errMsg); | |||
| if (pushLimit.getCouponDay() > 0) { | |||
| params.put("couponId", couponId); | |||
| params.put("dayNum", pushLimit.getCouponDay()-1); | |||
| int countForUserCoupon = wxCouponActionLogMapper.getCountByUserAndCoupon(params); | |||
| if (countForUserCoupon >= 1) { | |||
| String errMsg = "每人" + pushLimit.getCouponDay() + "天领一张券已到疲劳度上限"; | |||
| logger.error(errMsg); | |||
| throw new MallinkException(ErrorCode.PUSH_LIMIT_UP_TO_COUPONLIMIT.getCode(), errMsg); | |||
| } | |||
| } | |||
| return true; | |||
| @@ -301,7 +301,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| List<WxCouponMerchant> couponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); | |||
| if (!couponMerchantList.stream().anyMatch(cm->cm.getMerchantId().equals(wxMerchantBUser.getMerchantId()))){ | |||
| logger.error("券: coupon-" + wxCoupon.getId() + "核销: couponMerchantId-" + wxMerchantBUser.getMerchantId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERANT_IS_NULL); | |||
| } | |||
| } | |||
| @@ -255,23 +255,22 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); | |||
| List<WxProfitSharingReceiver> psReceiverList = wxProfitSharingReceiverMapper.findList(psReceiverQ); | |||
| if (psReceiverList.size() < 0 || psReceiverList.size() > 50) { | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||
| } | |||
| if (psReceiverList.size() == 0) { //没有分账账户,直接分入商户号 | |||
| WxProfitSharingReceiver receiver = new WxProfitSharingReceiver(); | |||
| receiver.setReceiverAccount(payAccount.getSubMchId()); | |||
| receiver.setReceiverType(EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_MERCHANT_ID.getCode()); | |||
| receiver.setSharingAmount(sharingOrderDto.getShareAmount()); | |||
| receiver.setParameter(null); | |||
| receiver.setId(0L); | |||
| psReceiverList.add(receiver); | |||
| if (psReceiverList.size() == 0) { //没有分账账户,直接结束分账 | |||
| if (sharingOrderDto.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode())) | |||
| sharingOrderDto.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE_FINISH.getCode()); | |||
| if (sharingOrderDto.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode())) | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||
| return finishSharingOrder(sharingOrderDto); | |||
| } | |||
| //计算分账账户合法性 | |||
| if (psReceiverList.size() > 1 && | |||
| psReceiverList.stream().filter(r->(r.getParameter() == null)).count() > 0) { | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||
| } | |||
| //计算分账金额合法性 | |||
| @@ -284,7 +283,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| } | |||
| }); | |||
| if (psReceiverList.stream().mapToInt(r->r.getSharingAmount()).sum() > sharingOrderDto.getShareAmount()){ | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID); | |||
| } | |||
| //单次分账检查是否已创建分账订单 | |||
| @@ -309,7 +309,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| wxPropertyContract.setDeposit(record.getDeposit()); | |||
| wxPropertyContract.setReceivePeriod(record.getReceivePeriod()); | |||
| wxPropertyContract.setPayAccount(record.getPayAccount()); | |||
| billList = buildProperty(new WxMerchant(),userId,wxPropertyContract,EnumIsPreview.YES.getCode()); | |||
| billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode()); | |||
| record.setPreviewBillRentList(billList); | |||
| } | |||
| } | |||
| @@ -13,10 +13,7 @@ import com.iformall.domain.po.*; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxFlowRecordService; | |||
| import com.iformall.service.WxFlowService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.WxRentContractService; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.apache.commons.collections.map.HashedMap; | |||
| @@ -98,6 +95,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Autowired | |||
| WxMerchantShopMapper wxMerchantShopMapper; | |||
| @Autowired | |||
| WxShopService wxShopService; | |||
| @Override | |||
| public Map<String, Object> listAsPage(WxRentContract record, Integer pageIndex, Integer pageSize) { | |||
| @@ -127,17 +126,23 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| wxRentContract.setPrice(wxRentContract.getPrice() != null ? wxRentContract.getPrice() : 0); | |||
| wxRentContract.setDeposit(wxRentContract.getDeposit() != null ? wxRentContract.getDeposit() : 0); | |||
| //handle adjustPeriod 1日 2月 monthHandleType 2按账单周期 3按自然月 | |||
| if(wxRentContract.getAdjustPeriod().intValue() == 1){ | |||
| wxRentContract.setAdjustPeriod(1); | |||
| wxRentContract.setMonthHandleType(null); | |||
| }else if(wxRentContract.getAdjustPeriod().intValue() == 2){ | |||
| wxRentContract.setAdjustPeriod(2); | |||
| wxRentContract.setMonthHandleType(2); | |||
| }else if(wxRentContract.getAdjustPeriod().intValue() == 3){ | |||
| wxRentContract.setAdjustPeriod(2); | |||
| wxRentContract.setMonthHandleType(3); | |||
| //目前只有多经点位租赁合同 | |||
| WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); | |||
| if(wxShop !=null && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ | |||
| //handle adjustPeriod 1日 2月 monthHandleType 2按账单周期 3按自然月 | |||
| if(wxRentContract.getAdjustPeriod().intValue() == 1){ | |||
| wxRentContract.setAdjustPeriod(1); | |||
| wxRentContract.setMonthHandleType(null); | |||
| }else if(wxRentContract.getAdjustPeriod().intValue() == 2){ | |||
| wxRentContract.setAdjustPeriod(2); | |||
| wxRentContract.setMonthHandleType(2); | |||
| }else if(wxRentContract.getAdjustPeriod().intValue() == 3){ | |||
| wxRentContract.setAdjustPeriod(2); | |||
| wxRentContract.setMonthHandleType(3); | |||
| } | |||
| } | |||
| result.put("wxRentContract", wxRentContract); | |||
| //关联的商户 | |||
| if (wxRentContract.getMerchantId() != null) { | |||
| @@ -2032,6 +2037,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| wxRentContractMapper.updateApplyStatus(wxRentContract); | |||
| } | |||
| @Override | |||
| public Integer getShopType(WxRentContract wxRentContract) { | |||
| return wxRentContractMapper.getShopType(wxRentContract); | |||
| } | |||
| } | |||
| @@ -28,7 +28,7 @@ | |||
| (case when | |||
| (select count(*) from wx_coupon_merchant xcm where xcm.product_id = cs.coupon_id and xcm.status = 0)=1 | |||
| then | |||
| (select m.name from wx_merchant m, wx_coupon_merchant cm where m.id = cm.merchant_id and cm.product_id=cs.coupon_id) | |||
| (select m.name from wx_merchant m, wx_coupon_merchant cm where m.id = cm.merchant_id and cm.product_id=cs.coupon_id and cm.status = 0) | |||
| else | |||
| '[多商户通用]' | |||
| end) as merchant_name, | |||
| @@ -271,5 +271,10 @@ | |||
| </where> | |||
| </select> | |||
| <select id="getShopType" parameterType="com.iformall.domain.po.WxRentContract" resultType="int"> | |||
| select s.type from wx_rent_contract r left join wx_shop s on(s.id = r.`shop_id`) | |||
| where r.id = #{id} | |||
| </select> | |||
| </mapper> | |||