| @@ -20,6 +20,7 @@ import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.math.BigDecimal; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -143,55 +144,100 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| if(status != null){ | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setPayDate(new Date()); | |||
| } | |||
| wxBillRentMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else if(EnumBillType.DEPOSIT.getCode().equals(bill.getBillType())) { | |||
| WxBillDeposit wxBillRent = new WxBillDeposit(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| if(status != null){ | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setPayDate(new Date()); | |||
| } | |||
| wxBillDepositMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| WxBillOtherDeposit wxBillOtherDeposit = new WxBillOtherDeposit(); | |||
| wxBillOtherDeposit.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxBillOtherDeposit.setFreeze(freezeStatus); | |||
| if(status != null){ | |||
| wxBillOtherDeposit.setStatus(status); | |||
| wxBillOtherDeposit.setPayDate(new Date()); | |||
| } | |||
| wxBillOtherDepositMapper.updateByPrimaryKeySelective(wxBillOtherDeposit); | |||
| WxBillPropertyDeposit propertyDeposit = new WxBillPropertyDeposit(); | |||
| propertyDeposit.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null){ | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setPayDate(new Date()); | |||
| } | |||
| wxBillPropertyDepositMapper.updateByPrimaryKeySelective(propertyDeposit); | |||
| }else if(EnumBillType.PROPERTY.getCode().equals(bill.getBillType())) { | |||
| WxBillProperty wxBillRent = new WxBillProperty(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| if(status != null){ | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setPayDate(new Date()); | |||
| } | |||
| wxBillPropertyMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| WxBillPropertyDeposit propertyDeposit = new WxBillPropertyDeposit(); | |||
| propertyDeposit.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| if(status != null){ | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setPayDate(new Date()); | |||
| } | |||
| wxBillPropertyDepositMapper.updateByPrimaryKeySelective(propertyDeposit); | |||
| }else if(EnumBillType.ROUTINE.getCode().equals(bill.getBillType())) { | |||
| WxBillOther wxBillRent = new WxBillOther(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| if(status != null){ | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setPayDate(new Date()); | |||
| } | |||
| wxBillOtherMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else if(EnumBillType.OTHER_DEPOSIT.getCode().equals(bill.getBillType())) { | |||
| WxBillOtherDeposit wxBillRent = new WxBillOtherDeposit(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| if(status != null){ | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setPayDate(new Date()); | |||
| } | |||
| wxBillOtherDepositMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| WxMerchantSubsidy wxMerchantSubsidy = new WxMerchantSubsidy(); | |||
| wxMerchantSubsidy.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxMerchantSubsidy.setFreeze(freezeStatus); | |||
| if(status != null) wxMerchantSubsidy.setStatus(status); | |||
| if(status != null){ | |||
| wxMerchantSubsidy.setStatus(status); | |||
| } | |||
| wxMerchantSubsidyMapper.updateByPrimaryKeySelective(wxMerchantSubsidy); | |||
| }else if(EnumBillType.OTHER_DEPOSIT.getCode().equals(bill.getBillType())) { | |||
| WxBillOtherDeposit wxBillRent = new WxBillOtherDeposit(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| if(status != null){ | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setPayDate(new Date()); | |||
| } | |||
| wxBillOtherDepositMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else{ | |||
| WxBillDaily wxBillRent = new WxBillDaily(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| if(freezeStatus != null) wxBillRent.setFreeze(freezeStatus); | |||
| if(status != null) wxBillRent.setStatus(status); | |||
| if(status != null){ | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setPayDate(new Date()); | |||
| } | |||
| wxBillDailyMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| } | |||
| } | |||
| @@ -340,7 +340,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| // 库存加锁 | |||
| if (!redisLock.lock(couponIdStr, timeStr)) { | |||
| logger.error("此券被锁定, couponId: " + couponIdStr); | |||
| throw new MallinkException(ErrorCode.TOO_MANY_REQUEST); | |||
| throw new MallinkException(ErrorCode.TOO_MANY_REQUEST.getCode(), coupon.getTitle() + ErrorCode.TOO_MANY_REQUEST.getMessage()); | |||
| } | |||
| JSONObject jo = JSONObject.parseObject(wxCouponSendVo.getConditions()) ; | |||
| @@ -352,7 +352,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| //解锁 | |||
| redisLock.unlock(couponIdStr, timeStr); | |||
| logger.error("此券库存为0, couponId: " + couponIdStr); | |||
| throw new MallinkException(ErrorCode.REMAIN_IS_EMPTY); | |||
| throw new MallinkException(ErrorCode.REMAIN_IS_EMPTY.getCode(), coupon.getTitle() + ErrorCode.REMAIN_IS_EMPTY.getMessage()); | |||
| } | |||
| int count = 0; | |||
| @@ -385,7 +385,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| //解锁 | |||
| redisLock.unlock(couponIdStr, timeStr); | |||
| logger.error("此券购买数量已超限, couponId: " + couponIdStr + ", count: " + count); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_LIMITED); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_LIMITED.getCode(), coupon.getTitle() + ErrorCode.ORDER_IS_LIMITED.getMessage()); | |||
| } | |||
| try { | |||
| @@ -393,7 +393,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| wxCouponSendService.reduceMerchantSend(wxCouponSendVo.getId(), merchantRemain,merchantSend,1); | |||
| } catch (RuntimeException e) { | |||
| logger.error("此券减库存失败, couponId: {}, error: {}", couponIdStr, e.getMessage()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), coupon.getTitle() + ErrorCode.ORDER_IS_LIMITED.getMessage()); | |||
| } finally { | |||
| //解锁 | |||
| redisLock.unlock(couponIdStr, timeStr); | |||
| @@ -747,11 +747,11 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } | |||
| if (coupon.getStatus() == EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode()) { | |||
| logger.error("券已下架, couponId: " + couponIdStr); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF.getCode(), coupon.getTitle() + ErrorCode.COUPON_IS_TAKE_OFF.getMessage()); | |||
| } | |||
| if (coupon.getSalePrice() != 0) { | |||
| logger.error("券不免费, couponId: " + couponIdStr); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_NOT_FREE); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_NOT_FREE.getCode(), coupon.getTitle() + ErrorCode.COUPON_IS_NOT_FREE.getMessage()); | |||
| } | |||
| if (Objects.nonNull(wxCouponSendVo) && Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), wxCouponSendVo.getSendType())) { | |||
| @@ -792,7 +792,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| wxOrderMapper.insertSelective(record); | |||
| } catch (Exception e) { | |||
| logger.error("保存订单:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); | |||
| throw new MallinkException(ErrorCode.ORDER_SAVE_ERR.getCode(), coupon.getTitle() + ErrorCode.ORDER_SAVE_ERR.getMessage()); | |||
| } | |||
| // 创建couponOrder | |||
| @@ -801,7 +801,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| couponOrder = createCouponOrder(record, user, coupon); | |||
| } catch (Exception e) { | |||
| logger.error("保存订单:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR.getCode(), coupon.getTitle() + ErrorCode.COUPON_ORDER_SAVE_ERR.getMessage()); | |||
| } | |||
| return couponOrder; | |||
| @@ -291,7 +291,7 @@ | |||
| union all | |||
| select s.settle_number,s.id,s.merchant_id,'' shop_id,s.tenant_id,'结算单' name, 10 bill_type_value,'结算单' bill_type,0 need_pay, | |||
| ((select IFNULL(sum(bill.receive_pay),0) from wx_bill_settle_bill bb left join | |||
| ((select IFNULL(sum(bill.owe),0) from wx_bill_settle_bill bb left join | |||
| (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 | |||
| union all | |||
| @@ -330,7 +330,7 @@ | |||
| ) bill | |||
| on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=0) | |||
| - | |||
| (select IFNULL(sum(bill.receive_pay),0) from wx_bill_settle_bill bb left join | |||
| (select IFNULL(sum(bill.owe),0) from wx_bill_settle_bill bb left join | |||
| (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 | |||
| union all | |||
| @@ -365,7 +365,7 @@ | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit | |||
| union all | |||
| select id,id merchant_id,'' shop_id,tenant_id,10 bill_type_value,'补贴' bill_type,0 as | |||
| need_pay,subsidy receive_pay,0 pay,0 owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type from wx_merchant_subsidy | |||
| need_pay,subsidy receive_pay,0 pay,subsidy owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type from wx_merchant_subsidy | |||
| ) bill | |||
| on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=1 | |||
| ) | |||
| @@ -381,7 +381,6 @@ | |||
| left join wx_pay_bill pb on bill.id=pb.bill_id | |||
| where 1=1 | |||
| <if test=" null != id "> | |||
| and bill.id=#{id} | |||
| </if> | |||
| @@ -47,41 +47,41 @@ | |||
| <select id="findBySettleId" parameterType="com.iformall.domain.po.WxBillSettleBill" resultMap="BaseResultMap"> | |||
| select bill.starttime,bill.endtime,bl.bill_id,bl.bill_type,bill.bill_type billName,IFNULL(bill.receive_pay,0) receivePay from wx_bill_settle_bill bl left join | |||
| (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' | |||
| (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金-租金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_rent where is_preview = 0 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金' | |||
| select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金-租赁押金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from | |||
| wx_bill_rent_deposit | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费' | |||
| select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费-物业费' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from | |||
| wx_bill_property where is_preview = 0 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金' | |||
| select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金-物业押金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from | |||
| wx_bill_property_deposit | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as | |||
| select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费-水费' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where | |||
| type=1 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as | |||
| select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费-电费' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where | |||
| type=2 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费' bill_type,0 as | |||
| select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费-空调费' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where | |||
| type=3 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他费用' bill_type,0 as | |||
| select id,merchant_id,shop_id,tenant_id,7 bill_type_value,concat('其他费用-',name) as bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_other | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as | |||
| select id,merchant_id,shop_id,tenant_id,8 bill_type_value,concat('其他押金-',comments) as bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_other_deposit | |||
| union all | |||
| select id, id merchant_id,'' shop_id,tenant_id,10 bill_type_value,'补贴' bill_type,0 as | |||
| select id, id merchant_id,'' shop_id,tenant_id,10 bill_type_value,'补贴-补贴' bill_type,0 as | |||
| need_pay,subsidy receive_pay,0 pay,0 owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type,'' starttime,'' endtime from wx_merchant_subsidy | |||
| ) bill | |||
| on(bl.bill_id = bill.id) | |||
| @@ -34,7 +34,7 @@ | |||
| and tt.createtime <= #{endtime} | |||
| </if> | |||
| <if test=" null != settleNumber and settleNumber !='' ">and tt.`settle_number` = #{settleNumber}</if> | |||
| <if test=" null != status and status !=''">and tt.`status` = #{status}</if> | |||
| <if test=" null != status">and tt.`status` = #{status}</if> | |||
| <if test=" null != applyStatus">and tt.`apply_status` = #{applyStatus}</if> | |||
| <if test="0 == direction"> | |||
| and (tt.receiveMoney-tt.payMoney- | |||
| @@ -55,7 +55,7 @@ | |||
| (select IFNULL(sum(settle_money),0) from wx_bill_settle_record where settle_id = tt.id) | |||
| ) balance from ( | |||
| select s.*,m.name merchantName, | |||
| (select IFNULL(sum(bill.receive_pay),0) from wx_bill_settle_bill bb left join | |||
| (select IFNULL(sum(bill.owe),0) from wx_bill_settle_bill bb left join | |||
| (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 | |||
| union all | |||
| @@ -91,7 +91,7 @@ | |||
| ) bill | |||
| on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=0 | |||
| ) receiveMoney, | |||
| (select IFNULL(sum(bill.receive_pay),0) from wx_bill_settle_bill bb left join | |||
| (select IFNULL(sum(bill.owe),0) from wx_bill_settle_bill bb left join | |||
| (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 | |||
| union all | |||
| @@ -126,7 +126,7 @@ | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit | |||
| union all | |||
| select id,id merchant_id,'' shop_id,tenant_id,10 bill_type_value,'补贴' bill_type,0 as | |||
| need_pay,subsidy receive_pay,0 pay,0 owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type from wx_merchant_subsidy | |||
| need_pay,subsidy receive_pay,0 pay,subsidy owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type from wx_merchant_subsidy | |||
| ) bill | |||
| on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=1 | |||