| @@ -9,6 +9,7 @@ import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.WxCardSpendMerchantVo; | |||||
| import com.iformall.domain.vo.WxCardSpendVo; | import com.iformall.domain.vo.WxCardSpendVo; | ||||
| import com.iformall.domain.vo.WxCardVo; | import com.iformall.domain.vo.WxCardVo; | ||||
| import com.iformall.enums.EnumMerchantSubsidySource; | import com.iformall.enums.EnumMerchantSubsidySource; | ||||
| @@ -62,7 +63,6 @@ public class WxCardPayController extends BaseController { | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
| @SystemControllerLog(description = "储值卡支付-售卡记录列表") | |||||
| public ResultData cardOrderList(@ModelAttribute WxCardVo wxCardVo, Integer pageNum, Integer pageSize) { | public ResultData cardOrderList(@ModelAttribute WxCardVo wxCardVo, Integer pageNum, Integer pageSize) { | ||||
| String ipStr = getIpAddr(); | String ipStr = getIpAddr(); | ||||
| if (wxCardVo == null) {wxCardVo = new WxCardVo();} | if (wxCardVo == null) {wxCardVo = new WxCardVo();} | ||||
| @@ -92,7 +92,6 @@ public class WxCardPayController extends BaseController { | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
| @SystemControllerLog(description = "储值卡支付-储值卡交易流水") | |||||
| public ResultData cardSpendlist(@ModelAttribute WxCardSpendVo wxCardSpendVo, Integer pageNum, Integer pageSize) { | public ResultData cardSpendlist(@ModelAttribute WxCardSpendVo wxCardSpendVo, Integer pageNum, Integer pageSize) { | ||||
| String ipStr = getIpAddr(); | String ipStr = getIpAddr(); | ||||
| logger.info("cardPay/cardSpendlist: " + ipStr); | logger.info("cardPay/cardSpendlist: " + ipStr); | ||||
| @@ -100,20 +99,6 @@ public class WxCardPayController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | ||||
| } | } | ||||
| wxCardSpendVo.updateTenantInfo(getTenantInfo()); | wxCardSpendVo.updateTenantInfo(getTenantInfo()); | ||||
| if(StringUtils.isNotBlank(wxCardSpendVo.getPayStatusStr())) { | |||||
| String [] statusAttr = wxCardSpendVo.getPayStatusStr().split(","); | |||||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||||
| for(String status: statusAttr) { | |||||
| tmpList.add(Integer.valueOf(status)); | |||||
| } | |||||
| if(!tmpList.isEmpty()) { | |||||
| wxCardSpendVo.setPayStatusS(tmpList); | |||||
| } | |||||
| } | |||||
| //List<Integer> sources = new ArrayList<Integer>(); | |||||
| //sources.add(EnumMerchantSubsidySource.CARD.getCode()); | |||||
| //wxCardSpendVo.setSources(sources); | |||||
| // wxCardSpendVo.setCardSpendListShow(1); | |||||
| wxCardSpendVo.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | wxCardSpendVo.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | ||||
| final PageInfo<WxCardSpendVo> page = wxCardSpendService.listAsPage(wxCardSpendVo, pageNum, pageSize); | final PageInfo<WxCardSpendVo> page = wxCardSpendService.listAsPage(wxCardSpendVo, pageNum, pageSize); | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| @@ -121,16 +106,11 @@ public class WxCardPayController extends BaseController { | |||||
| @ApiOperation("储值卡交易流水SUM") | @ApiOperation("储值卡交易流水SUM") | ||||
| @GetMapping("sum") | @GetMapping("sum") | ||||
| @SystemControllerLog(description = "储值卡支付-储值卡交易流水SUM") | |||||
| public ResultData sumCard(@ModelAttribute WxCardSpendVo wxCardSpend) { | public ResultData sumCard(@ModelAttribute WxCardSpendVo wxCardSpend) { | ||||
| if (wxCardSpend == null) { | if (wxCardSpend == null) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | ||||
| } | } | ||||
| wxCardSpend.updateTenantInfo(getTenantInfo()); | wxCardSpend.updateTenantInfo(getTenantInfo()); | ||||
| // List<Integer> sources = new ArrayList<Integer>(); | |||||
| // sources.add(EnumMerchantSubsidySource.CARD.getCode()); | |||||
| // wxCardSpend.setSources(sources); | |||||
| // wxCardSpend.setCardSpendListShow(1); | |||||
| final Map<String, BigDecimal> mapList = wxCardSpendService.sumCardSpend(wxCardSpend); | final Map<String, BigDecimal> mapList = wxCardSpendService.sumCardSpend(wxCardSpend); | ||||
| return new ResultData(mapList); | return new ResultData(mapList); | ||||
| } | } | ||||
| @@ -156,6 +136,43 @@ public class WxCardPayController extends BaseController { | |||||
| } | } | ||||
| wxCardSpendService.exportData(wxCardSpendVo, request, response); | wxCardSpendService.exportData(wxCardSpendVo, request, response); | ||||
| } | } | ||||
| @ApiOperation("商户储值卡交易流水(消费记录 + 补贴)列表接口") | |||||
| @GetMapping("merchantCardSpendlist") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData merchantCardSpendlist(@ModelAttribute WxCardSpendVo wxCardSpendVo, Integer pageNum, Integer pageSize) { | |||||
| if (wxCardSpendVo == null) { | |||||
| wxCardSpendVo = new WxCardSpendVo(); | |||||
| } | |||||
| wxCardSpendVo.updateTenantInfo(getTenantInfo()); | |||||
| wxCardSpendVo.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| final PageInfo<WxCardSpendMerchantVo> page = wxCardSpendService.listMerchantAsPage(wxCardSpendVo, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("商户储值卡交易流水SUM") | |||||
| @GetMapping("sumMerchant") | |||||
| public ResultData sumMerchant(@ModelAttribute WxCardSpendVo wxCardSpend) { | |||||
| if (wxCardSpend == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||||
| } | |||||
| wxCardSpend.updateTenantInfo(getTenantInfo()); | |||||
| final Map<String, BigDecimal> mapList = wxCardSpendService.sumCardSpend(wxCardSpend); | |||||
| return new ResultData(mapList); | |||||
| } | |||||
| @ApiOperation("商户储值卡交易流水导出") | |||||
| @GetMapping("/exportMerchantData") | |||||
| @SystemControllerLog(description = "储值卡支付-商户储值卡交易流水导出") | |||||
| public void exportMerchantData(@ModelAttribute WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response) { | |||||
| if (wxCardSpendVo == null) { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||||
| } | |||||
| wxCardSpendVo.updateTenantInfo(getTenantInfo()); | |||||
| wxCardSpendService.exportMerchantData(wxCardSpendVo, request, response); | |||||
| } | |||||
| @ApiOperation("更新卡消费支付状态") | @ApiOperation("更新卡消费支付状态") | ||||
| @PostMapping("/updatePayStatus") | @PostMapping("/updatePayStatus") | ||||
| @@ -22,6 +22,8 @@ set ci.coupon_password = cp.password where ci.coupon_password is null | |||||
| alter table wx_coupon_password add column is_stop int(1) not null default 0 comment '是否已停止1-是,0-否'; | alter table wx_coupon_password add column is_stop int(1) not null default 0 comment '是否已停止1-是,0-否'; | ||||
| alter table wx_card_spend add column subsidy int(11) not null default 0 comment '补贴金额'; | |||||
| @@ -171,7 +171,7 @@ public class WxCardPayController extends BaseController { | |||||
| logger.error("卡不存在: " + cardIdStr); | logger.error("卡不存在: " + cardIdStr); | ||||
| return new ResultData(ErrorCode.CARD_IS_NOT_FOUND); | return new ResultData(ErrorCode.CARD_IS_NOT_FOUND); | ||||
| } | } | ||||
| return saveCardPayOrder(cUserId,cardInfo,merchantBUser,totalFeeStr,EnumPayWay.PAY_WAY_WECHAT); | |||||
| return saveCardPayOrder(cUserId,cardInfo,merchantBUser,totalFeeStr,true); | |||||
| } | } | ||||
| public ResultData savePasswordCardPayOrder(String cardIdStr,String totalFeeStr) { | public ResultData savePasswordCardPayOrder(String cardIdStr,String totalFeeStr) { | ||||
| @@ -203,10 +203,10 @@ public class WxCardPayController extends BaseController { | |||||
| } | } | ||||
| WxCardInfo carInfo = wxCardInfoService.cardCreateByOffline(couponPassword, coupon); | WxCardInfo carInfo = wxCardInfoService.cardCreateByOffline(couponPassword, coupon); | ||||
| return saveCardPayOrder(Constant.defaultCUserId,carInfo,merchantBUser,totalFeeStr,EnumPayWay.PAY_WAY_WECHAT); | |||||
| return saveCardPayOrder(Constant.defaultCUserId,carInfo,merchantBUser,totalFeeStr,false); | |||||
| } | } | ||||
| private ResultData saveCardPayOrder(Long cUserId,WxCardInfo cardInfo,WxMerchantBUser merchantBUser,String totalFeeStr,EnumPayWay payWay) { | |||||
| private ResultData saveCardPayOrder(Long cUserId,WxCardInfo cardInfo,WxMerchantBUser merchantBUser,String totalFeeStr,boolean isEcard) { | |||||
| if (EnumCardInfoStatus.STOP.getCode().intValue() == cardInfo.getStatus().intValue()) { | if (EnumCardInfoStatus.STOP.getCode().intValue() == cardInfo.getStatus().intValue()) { | ||||
| return new ResultData(ErrorCode.CARD_IS_NOT_FOUND.getCode(),"卡已被禁用."); | return new ResultData(ErrorCode.CARD_IS_NOT_FOUND.getCode(),"卡已被禁用."); | ||||
| @@ -259,7 +259,7 @@ public class WxCardPayController extends BaseController { | |||||
| WxOrder order = null; | WxOrder order = null; | ||||
| try { | try { | ||||
| order = wxOrderService.saveCardPayOrder(merchant, cUserId, totalFeeStr, payment,payWay); | |||||
| order = wxOrderService.saveCardPayOrder(merchant, cUserId, totalFeeStr, payment); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("saveCardPayOrder 1" + e.getMessage()); | logger.error("saveCardPayOrder 1" + e.getMessage()); | ||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| @@ -276,11 +276,14 @@ public class WxCardPayController extends BaseController { | |||||
| record.setOrderId(order.getId()); | record.setOrderId(order.getId()); | ||||
| record.setIp(ipStr); | record.setIp(ipStr); | ||||
| record.setDeductionAmount(payment); | record.setDeductionAmount(payment); | ||||
| record.setRemark("操作于["+payWay.getMessage()+"("+payWay.getCode()+")]"); | |||||
| if (isEcard) { | |||||
| record.setRemark("操作于[B扫C电子卡支付]"); | |||||
| }else { | |||||
| record.setRemark("操作于[B扫C实体卡支付]"); | |||||
| } | |||||
| Integer couponNumber = null; | |||||
| try { | try { | ||||
| return wxCardSpendService.createCardSpend(record, order, couponMerchant,payWay); | |||||
| return wxCardSpendService.createCardSpend(record, order, couponMerchant); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("card spend error, req 2: " + record.toString() + ", e:" + e.getMessage()); | logger.error("card spend error, req 2: " + record.toString() + ", e:" + e.getMessage()); | ||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| @@ -90,10 +90,10 @@ public class WxCardPayController extends BaseController { | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| return new ResultData(Result.ERROR,e.getMessage()); | return new ResultData(Result.ERROR,e.getMessage()); | ||||
| } | } | ||||
| return saveCardPayOrder(memberId,cardIdStr,merchantStr,totalFeeStr,EnumPayWay.PAY_WAY_WECHAT); | |||||
| return saveCardPayOrder(memberId,cardIdStr,merchantStr,totalFeeStr); | |||||
| } | } | ||||
| private ResultData saveCardPayOrder(Long cUserId,String cardIdStr,String merchantStr,String totalFeeStr,EnumPayWay payWay) { | |||||
| private ResultData saveCardPayOrder(Long cUserId,String cardIdStr,String merchantStr,String totalFeeStr) { | |||||
| String ipStr = getIpAddr(); | String ipStr = getIpAddr(); | ||||
| logger.info("saveCardPayOrder: " + ipStr + " : cUserId:{} , cardIdStr:{},merchantStr:{},totalFeeStr:{}",cUserId,cardIdStr,cardIdStr,cardIdStr); | logger.info("saveCardPayOrder: " + ipStr + " : cUserId:{} , cardIdStr:{},merchantStr:{},totalFeeStr:{}",cUserId,cardIdStr,cardIdStr,cardIdStr); | ||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(cUserId,getFinalTenantId()); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(cUserId,getFinalTenantId()); | ||||
| @@ -168,7 +168,7 @@ public class WxCardPayController extends BaseController { | |||||
| WxOrder order = null; | WxOrder order = null; | ||||
| try { | try { | ||||
| order = wxOrderService.saveCardPayOrder(merchant, cUserId, totalFeeStr, payment,payWay); | |||||
| order = wxOrderService.saveCardPayOrder(merchant, cUserId, totalFeeStr, payment); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("saveCardPayOrder 1" + e.getMessage()); | logger.error("saveCardPayOrder 1" + e.getMessage()); | ||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| @@ -185,10 +185,10 @@ public class WxCardPayController extends BaseController { | |||||
| record.setOrderId(order.getId()); | record.setOrderId(order.getId()); | ||||
| record.setIp(ipStr); | record.setIp(ipStr); | ||||
| record.setDeductionAmount(payment); | record.setDeductionAmount(payment); | ||||
| record.setRemark("操作于["+payWay.getMessage()+"("+payWay.getCode()+")]"); | |||||
| record.setRemark("操作于[C扫B支付]"); | |||||
| try { | try { | ||||
| return wxCardSpendService.createCardSpend(record, order, couponMerchant,payWay); | |||||
| return wxCardSpendService.createCardSpend(record, order, couponMerchant); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("card spend error, req 2: " + record.toString() + ", e:" + e.getMessage()); | logger.error("card spend error, req 2: " + record.toString() + ", e:" + e.getMessage()); | ||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| @@ -45,7 +45,8 @@ public class WxCardSpend extends TenantEntity { | |||||
| private Integer payment; | private Integer payment; | ||||
| @io.swagger.annotations.ApiModelProperty(value="实收金额(不包含通道费)",name="realPayment") | @io.swagger.annotations.ApiModelProperty(value="实收金额(不包含通道费)",name="realPayment") | ||||
| private Integer realPayment; | private Integer realPayment; | ||||
| @io.swagger.annotations.ApiModelProperty(value="补贴",name="subsidy") | |||||
| private Integer subsidy; | |||||
| @io.swagger.annotations.ApiModelProperty(value="卡剩余总金额",name="cardRemainAmount") | @io.swagger.annotations.ApiModelProperty(value="卡剩余总金额",name="cardRemainAmount") | ||||
| private Integer cardRemainAmount; | private Integer cardRemainAmount; | ||||
| @io.swagger.annotations.ApiModelProperty(value="卡支付前总金额",name="cardBeforeAmount") | @io.swagger.annotations.ApiModelProperty(value="卡支付前总金额",name="cardBeforeAmount") | ||||
| @@ -0,0 +1,23 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
| import java.math.BigDecimal; | |||||
| import lombok.Data; | |||||
| import lombok.ToString; | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| public class WxCardSpendMerchantVo { | |||||
| @Excel(name = "商户编号", width = 20,orderNum = "1") | |||||
| private Long merchantId; | |||||
| @Excel(name = "商户名称", width = 20, orderNum = "2") | |||||
| private String merchantName; | |||||
| @Excel(name = "交易总金额", width = 20, orderNum = "3") | |||||
| private BigDecimal total; | |||||
| @Excel(name = "总手续费", width = 20, orderNum = "4") | |||||
| private BigDecimal fee; | |||||
| @Excel(name = "总补贴", width = 20, orderNum = "5") | |||||
| private BigDecimal subsidy; | |||||
| } | |||||
| @@ -6,6 +6,7 @@ import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.iformall.domain.po.WxCardInfo; | |||||
| import com.iformall.domain.po.WxCardSpend; | import com.iformall.domain.po.WxCardSpend; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| @@ -56,5 +57,6 @@ public class WxCardSpendVo extends WxCardSpend { | |||||
| private Date couponOnlineStartDate; | private Date couponOnlineStartDate; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Date couponOnlineEndDate; | private Date couponOnlineEndDate; | ||||
| @TableField(exist = false) | |||||
| private WxCardInfo wxCardInfo; | |||||
| } | } | ||||
| @@ -15,6 +15,7 @@ public interface WxCardSpendMapper extends CommonMapper<WxCardSpend, Long> { | |||||
| int findCount(WxCardSpend wxCardSpend); | int findCount(WxCardSpend wxCardSpend); | ||||
| List<Map<String,Object>> getMerchantCount(WxCardSpend wxCardSpend); | List<Map<String,Object>> getMerchantCount(WxCardSpend wxCardSpend); | ||||
| List<Map<String,Object>> sumMerchant(WxCardSpend wxCardSpend); | |||||
| List<Long> getMerchantIdList(WxCardSpend wxCardSpend); | List<Long> getMerchantIdList(WxCardSpend wxCardSpend); | ||||
| @@ -5,6 +5,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.PromotionCalc; | import com.iformall.domain.vo.PromotionCalc; | ||||
| import com.iformall.domain.vo.WxCardSpendMerchantVo; | |||||
| import com.iformall.domain.vo.WxCardSpendVo; | import com.iformall.domain.vo.WxCardSpendVo; | ||||
| import com.iformall.enums.EnumPayWay; | import com.iformall.enums.EnumPayWay; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| @@ -30,7 +31,7 @@ public interface WxCardSpendService { | |||||
| * @param order | * @param order | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| ResultData createCardSpend(WxCardSpend record, WxOrder order, WxCouponMerchant couponMerchant,EnumPayWay payWay); | |||||
| ResultData createCardSpend(WxCardSpend record, WxOrder order, WxCouponMerchant couponMerchant); | |||||
| /** | /** | ||||
| * 根据实体查询分页列表 | * 根据实体查询分页列表 | ||||
| @@ -41,6 +42,8 @@ public interface WxCardSpendService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<WxCardSpendVo> listAsPage(WxCardSpendVo record, Integer pageIndex, Integer pageSize); | PageInfo<WxCardSpendVo> listAsPage(WxCardSpendVo record, Integer pageIndex, Integer pageSize); | ||||
| PageInfo<WxCardSpendMerchantVo> listMerchantAsPage(WxCardSpendVo record, Integer pageIndex, Integer pageSize); | |||||
| /** | /** | ||||
| * 根据实体SUM | * 根据实体SUM | ||||
| @@ -98,6 +101,7 @@ public interface WxCardSpendService { | |||||
| * cardPay交易流水导出 | * cardPay交易流水导出 | ||||
| */ | */ | ||||
| void exportData(WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response); | void exportData(WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response); | ||||
| void exportMerchantData(WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response); | |||||
| /** | /** | ||||
| * POS 卡支付相关接口 | * POS 卡支付相关接口 | ||||
| @@ -80,7 +80,7 @@ public interface WxOrderService { | |||||
| * @param payment | * @param payment | ||||
| * @return 订单id | * @return 订单id | ||||
| */ | */ | ||||
| WxOrder saveCardPayOrder(WxMerchant merchant, Long cUserId, String totalFeeStr, Integer payment,EnumPayWay payWay); | |||||
| WxOrder saveCardPayOrder(WxMerchant merchant, Long cUserId, String totalFeeStr, Integer payment); | |||||
| /** | /** | ||||
| * 免费券订单接口 | * 免费券订单接口 | ||||
| @@ -12,6 +12,7 @@ import com.iformall.domain.dto.WxSharingOrderDto; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.PromotionCalc; | import com.iformall.domain.vo.PromotionCalc; | ||||
| import com.iformall.domain.vo.WxCardSpendMerchantVo; | |||||
| import com.iformall.domain.vo.WxCardSpendVo; | import com.iformall.domain.vo.WxCardSpendVo; | ||||
| import com.iformall.domain.vo.WxCardVo; | import com.iformall.domain.vo.WxCardVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| @@ -122,7 +123,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public ResultData createCardSpend(WxCardSpend record, WxOrder order, WxCouponMerchant couponMerchant,EnumPayWay payWay) { | |||||
| public ResultData createCardSpend(WxCardSpend record, WxOrder order, WxCouponMerchant couponMerchant) { | |||||
| Date curDate = new Date(); | Date curDate = new Date(); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| // 1. get card info | // 1. get card info | ||||
| @@ -179,12 +180,6 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| record.setPayStatus(EnumCardSpendStatus.NOT_PAY.getCode()); | record.setPayStatus(EnumCardSpendStatus.NOT_PAY.getCode()); | ||||
| record.setCreateDate(curDate); | record.setCreateDate(curDate); | ||||
| record.setUpdateDate(curDate); | record.setUpdateDate(curDate); | ||||
| try { | |||||
| wxCardSpendMapper.insert(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("card spend insert error"); | |||||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "card spend 插入出错!"); | |||||
| } | |||||
| // 6. update order status | // 6. update order status | ||||
| WxOrder orderUpdate = new WxOrder(); | WxOrder orderUpdate = new WxOrder(); | ||||
| @@ -281,49 +276,31 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| } | } | ||||
| } | } | ||||
| //卡不再调用微信分账 | |||||
| // if (payAccount.checkShare()) { | |||||
| // // 分账 | |||||
| // if (cardInfo.getSaleAmount() > 0) { | |||||
| // // 9. 只有有价卡才能分账 | |||||
| // try { | |||||
| // shareForCardPay(record, record.getCardId(), record.getOrderId(), record.getId(),payWay.getCode()); | |||||
| // } catch (MallinkException e) { | |||||
| // logger.error(e.getMessage()); | |||||
| // if (ErrorCode.PROFIT_SHARING_NUM_UP_LIMIT.getCode() == e.getErrorCode() || | |||||
| // ErrorCode.PROFIT_SHARING_TIME_EXPIRED.getCode() == e.getErrorCode()) { | |||||
| // // 分账已到20次限制,后面只记录,不分账 | |||||
| // // 分账已过期,后面只记录,不分账 | |||||
| // logger.error("分账已到20次限制,后面只记录,无法分账"); | |||||
| // try { | |||||
| // creteMerchantSubsidy(record, curDate, idWorker, coupon, payment); | |||||
| // } catch (Exception ex) { | |||||
| // logger.error("分账已到20次限制,记录到结算表失败"); | |||||
| // } | |||||
| // } else { | |||||
| // throw new MallinkException(e.getErrorCode(), e.getMessage()); | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // } else { | |||||
| // 有价储值卡消费时,如果未启用分账,金额也记入补贴表,可能会导致查询错误, | |||||
| if (cardInfo.getSaleAmount() > 0) { | |||||
| if (payment > 0) { | |||||
| try { | |||||
| creteMerchantSubsidy(record, curDate, idWorker, coupon, payment); | |||||
| } catch (Exception ex) { | |||||
| logger.error("记录到结算表失败"); | |||||
| } | |||||
| } | |||||
| //更新商户余额 | |||||
| if (real_payment > 0) { | |||||
| Long merchantId = couponMerchant.getMerchantId(); | |||||
| WxMerchant merchant = wxMerchantMapper.selectById(merchantId); | |||||
| wxCashOutService.addCashOut(merchant, real_payment); | |||||
| } | |||||
| } | |||||
| // } | |||||
| try { | |||||
| record.setSubsidy(subsidyFee); | |||||
| wxCardSpendMapper.insert(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("card spend insert error"); | |||||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "card spend 插入出错!"); | |||||
| } | |||||
| // 有价储值卡消费时,如果未启用分账,金额也记入补贴表,可能会导致查询错误, | |||||
| if (cardInfo.getSaleAmount() > 0) { | |||||
| if (payment > 0) { | |||||
| try { | |||||
| creteMerchantSubsidy(record, curDate, idWorker, coupon, payment); | |||||
| } catch (Exception ex) { | |||||
| logger.error("记录到结算表失败"); | |||||
| } | |||||
| } | |||||
| //更新商户余额 | |||||
| if (real_payment > 0) { | |||||
| Long merchantId = couponMerchant.getMerchantId(); | |||||
| WxMerchant merchant = wxMerchantMapper.selectById(merchantId); | |||||
| wxCashOutService.addCashOut(merchant, real_payment); | |||||
| } | |||||
| } | |||||
| if (null != orderUpdate.getCUserId() && Constant.defaultCUserId != orderUpdate.getCUserId()) { | if (null != orderUpdate.getCUserId() && Constant.defaultCUserId != orderUpdate.getCUserId()) { | ||||
| // 成长值 | // 成长值 | ||||
| @@ -501,6 +478,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| Map<Long,Long> cardCouponIdMap = new HashMap<Long,Long>(); | Map<Long,Long> cardCouponIdMap = new HashMap<Long,Long>(); | ||||
| Map<Long,WxCardInfo> cardInfoMap = new HashMap<Long,WxCardInfo>(); | |||||
| if (cardInfoIdList.size() > 0 ){ | if (cardInfoIdList.size() > 0 ){ | ||||
| WxCardInfo ciq = new WxCardInfo(); | WxCardInfo ciq = new WxCardInfo(); | ||||
| ciq.updateTenantInfo(tenantEntity); | ciq.updateTenantInfo(tenantEntity); | ||||
| @@ -513,6 +491,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| couponIdList.add(ci.getCouponId()) ; | couponIdList.add(ci.getCouponId()) ; | ||||
| cardCouponIdMap.put(ci.getId(),ci.getCouponId()); | cardCouponIdMap.put(ci.getId(),ci.getCouponId()); | ||||
| } | } | ||||
| cardInfoMap.put(ci.getId(), ci); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -543,6 +522,11 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| vo.setTitle(coupon.getTitle()); | vo.setTitle(coupon.getTitle()); | ||||
| } | } | ||||
| } | } | ||||
| WxCardInfo cardInfo = cardInfoMap.get(_wcs.getCardId()) ; | |||||
| if (null != cardInfo) { | |||||
| vo.setWxCardInfo(cardInfo); | |||||
| } | |||||
| } | } | ||||
| if (null != _wcs.getOrderId()) { | if (null != _wcs.getOrderId()) { | ||||
| WxMerchantSubsidy subsidy = orderSubsidyMap.get(_wcs.getOrderId()); | WxMerchantSubsidy subsidy = orderSubsidyMap.get(_wcs.getOrderId()); | ||||
| @@ -583,7 +567,6 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| pageInfo.setTotal(cardInfoPage.getTotal()); | pageInfo.setTotal(cardInfoPage.getTotal()); | ||||
| return pageInfo; | return pageInfo; | ||||
| } | } | ||||
| private void handleQueryParam(WxCardSpendVo record){ | private void handleQueryParam(WxCardSpendVo record){ | ||||
| //处理券投放时间 | //处理券投放时间 | ||||
| @@ -607,20 +590,6 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| // if (null != record.getStatus() || null != record.getSources() || null != record.getCardSpendListShow()) { | |||||
| // WxMerchantSubsidy subq = new WxMerchantSubsidy(); | |||||
| // subq.updateTenantInfo(record); | |||||
| // subq.setStatus(record.getStatus()); | |||||
| // subq.setSourceList(record.getSources()); | |||||
| // subq.setCardSpendListShow(record.getCardSpendListShow()); | |||||
| // List<Long> orderList = wxMerchantSubsidyMapper.findOrderIdList(subq); | |||||
| // if (null == orderList || orderList.size() <=0 ){ | |||||
| // record.setId(-999L); | |||||
| // }else { | |||||
| // record.setOrderIdList(orderList); | |||||
| // } | |||||
| // } | |||||
| if (StringUtils.isNotBlank(record.getOuPhone())) { | if (StringUtils.isNotBlank(record.getOuPhone())) { | ||||
| WxCUserBasicInfo uq = new WxCUserBasicInfo(); | WxCUserBasicInfo uq = new WxCUserBasicInfo(); | ||||
| uq.setFinalTenantId(record.getFinalTenantId()); | uq.setFinalTenantId(record.getFinalTenantId()); | ||||
| @@ -633,41 +602,70 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public Map<String, BigDecimal> sumCardSpend(WxCardSpendVo record) { | |||||
| public PageInfo<WxCardSpendMerchantVo> listMerchantAsPage(WxCardSpendVo record, Integer pageIndex, Integer pageSize) { | |||||
| handleQueryParam(record); | handleQueryParam(record); | ||||
| //补贴暂时不算 | |||||
| // List<Long> merchantIdList = wxCardSpendMapper.getMerchantIdList(record); | |||||
| // Map<Long,WxMerchant> merchantMap = this.getMerchantMap(merchantIdList, record); | |||||
| // WxMerchantSubsidy sq = getWxMerchantSubsidyQuery(record,merchantIdList); | |||||
| // List<Map<String,Object>> merchantSubsidyMap = wxMerchantSubsidyMapper.sumByMerchantId(sq); | |||||
| // Map<Long,Map<String,BigDecimal>> msmap = new HashMap<Long,Map<String,BigDecimal>>(); | |||||
| // if (null != merchantSubsidyMap && merchantSubsidyMap.size() > 0 ) { | |||||
| // for (int i = 0 ; i < merchantSubsidyMap.size(); i++) { | |||||
| // Map<String,Object> result = merchantSubsidyMap.get(i) ; | |||||
| // Map<String,BigDecimal> submap = new HashMap<String,BigDecimal>(); | |||||
| // submap.put("sum_subsidy", (BigDecimal)result.get("sum_subsidy")); | |||||
| // submap.put("sum_real_subsidy", (BigDecimal)result.get("sum_real_subsidy")); | |||||
| // msmap.put((Long)result.get("merchant_id"), submap) ; | |||||
| // } | |||||
| // } | |||||
| return wxCardSpendMapper.sumCardSpend(record); | |||||
| PageInfo<Map<String,Object>> cardInfoPage = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCardSpendMapper.sumMerchant(record)); | |||||
| PageInfo<WxCardSpendMerchantVo> pageInfo = new PageInfo<WxCardSpendMerchantVo>(); | |||||
| pageInfo.setList(handleToCardSpendMerchantVoList(cardInfoPage.getList(),record)); | |||||
| pageInfo.setPageNum(cardInfoPage.getPageNum()); | |||||
| pageInfo.setPageSize(cardInfoPage.getPageSize()); | |||||
| pageInfo.setPages(cardInfoPage.getPages()); | |||||
| pageInfo.setTotal(cardInfoPage.getTotal()); | |||||
| return pageInfo; | |||||
| } | } | ||||
| private WxMerchantSubsidy getWxMerchantSubsidyQuery(WxCardSpendVo record,List<Long> merchantIdList) { | |||||
| WxMerchantSubsidy sq = new WxMerchantSubsidy(); | |||||
| sq.updateTenantInfo(record); | |||||
| sq.setStatus(record.getStatus()); | |||||
| sq.setSourceList(record.getSources()); | |||||
| sq.setCardSpendListShow(record.getCardSpendListShow()); | |||||
| if (null != merchantIdList && merchantIdList.size() > 0 ) { | |||||
| sq.setMerchantIdList(merchantIdList); | |||||
| private List<WxCardSpendMerchantVo> handleToCardSpendMerchantVoList(List<Map<String,Object>> list,TenantEntity tenantEntity) { | |||||
| if (null != list && list.size() > 0 ) { | |||||
| List<WxCardSpendMerchantVo> retList = new ArrayList<WxCardSpendMerchantVo>(); | |||||
| List<Long> merchantIdList = new ArrayList<Long>(); | |||||
| for (int i = 0 ; i < list.size(); i++ ) { | |||||
| Map<String,Object> m = list.get(i); | |||||
| WxCardSpendMerchantVo vo = new WxCardSpendMerchantVo(); | |||||
| Long merchantId = (Long)m.get("merchant_id"); | |||||
| vo.setMerchantId(merchantId); | |||||
| if (null != merchantId && (!merchantIdList.contains(merchantId))) { | |||||
| merchantIdList.add(merchantId); | |||||
| } | |||||
| vo.setTotal((BigDecimal)m.get("sum_deduction_amount")); | |||||
| BigDecimal payment = (BigDecimal)m.get("sum_payment"); | |||||
| if (null == payment) { | |||||
| payment = new BigDecimal(0); | |||||
| } | |||||
| BigDecimal realPayment = (BigDecimal)m.get("sum_real_payment"); | |||||
| if (null == realPayment) { | |||||
| realPayment = new BigDecimal(0); | |||||
| } | |||||
| vo.setFee(payment.subtract(realPayment)); | |||||
| //补贴 | |||||
| BigDecimal subsidy = (BigDecimal)m.get("sum_subsidy"); | |||||
| vo.setSubsidy(subsidy); | |||||
| retList.add(vo); | |||||
| } | |||||
| Map<Long,WxMerchant> merchantMap = this.getMerchantMap(merchantIdList, tenantEntity); | |||||
| if (retList.size() > 0 ) { | |||||
| for (int i = 0 ; i < retList.size(); i++ ){ | |||||
| WxCardSpendMerchantVo vo = retList.get(i); | |||||
| if (null != vo.getMerchantId()) { | |||||
| WxMerchant merchant = merchantMap.get(vo.getMerchantId()) ; | |||||
| if (null != merchant) { | |||||
| vo.setMerchantName(merchant.getName()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| return retList; | |||||
| } | } | ||||
| return sq; | |||||
| return null; | |||||
| } | } | ||||
| @Override | |||||
| public Map<String, BigDecimal> sumCardSpend(WxCardSpendVo record) { | |||||
| handleQueryParam(record); | |||||
| return wxCardSpendMapper.sumCardSpend(record); | |||||
| } | |||||
| @Override | @Override | ||||
| public WxCardSpend getById(Long id) { | public WxCardSpend getById(Long id) { | ||||
| return wxCardSpendMapper.selectById(id); | return wxCardSpendMapper.selectById(id); | ||||
| @@ -905,6 +903,13 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| List<WxCardSpendVo> list = listAsPage(record,0,50000).getList(); | List<WxCardSpendVo> list = listAsPage(record,0,50000).getList(); | ||||
| excelService.exportExcel(list, null, "卡消费记录", WxCardSpendVo.class, "卡消费记录.xlsx", response, false); | excelService.exportExcel(list, null, "卡消费记录", WxCardSpendVo.class, "卡消费记录.xlsx", response, false); | ||||
| } | } | ||||
| @Override | |||||
| public void exportMerchantData(WxCardSpendVo record, HttpServletRequest request, HttpServletResponse response) { | |||||
| handleQueryParam(record); | |||||
| List<WxCardSpendMerchantVo> list = listMerchantAsPage(record,0,50000).getList(); | |||||
| excelService.exportExcel(list, null, "商户卡消费统计", WxCardSpendMerchantVo.class, "商户卡消费统计.xlsx", response, false); | |||||
| } | |||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| @@ -1292,7 +1292,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public WxOrder saveCardPayOrder(WxMerchant merchant, Long cUserId, String totalFeeStr, Integer payment,EnumPayWay payWay) { | |||||
| public WxOrder saveCardPayOrder(WxMerchant merchant, Long cUserId, String totalFeeStr, Integer payment) { | |||||
| Date curr = new Date(); | Date curr = new Date(); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| @@ -1311,7 +1311,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| Long orderNumber = idWorker.nextId(); | Long orderNumber = idWorker.nextId(); | ||||
| // body | // body | ||||
| // tenant_id + merchant_id + title + subtitle | // tenant_id + merchant_id + title + subtitle | ||||
| String bodyStr = "["+payWay.getMessage()+"("+payWay.getCode()+")]C扫B储值卡支付, 金额:" + totalFeeStr; | |||||
| String bodyStr = "储值卡支付, 金额:" + totalFeeStr; | |||||
| WxOrder record = new WxOrder(); | WxOrder record = new WxOrder(); | ||||
| record.setId(orderNumber); | record.setId(orderNumber); | ||||
| @@ -13,6 +13,7 @@ | |||||
| <result column="deduction_amount" jdbcType="INTEGER" property="deductionAmount"/> | <result column="deduction_amount" jdbcType="INTEGER" property="deductionAmount"/> | ||||
| <result column="payment" jdbcType="INTEGER" property="payment"/> | <result column="payment" jdbcType="INTEGER" property="payment"/> | ||||
| <result column="real_payment" jdbcType="INTEGER" property="realPayment"/> | <result column="real_payment" jdbcType="INTEGER" property="realPayment"/> | ||||
| <result column="subsidy" jdbcType="INTEGER" property="subsidy"/> | |||||
| <result column="card_remain_amount" jdbcType="INTEGER" property="cardRemainAmount"/> | <result column="card_remain_amount" jdbcType="INTEGER" property="cardRemainAmount"/> | ||||
| <result column="card_before_amount" jdbcType="INTEGER" property="cardBeforeAmount"/> | <result column="card_before_amount" jdbcType="INTEGER" property="cardBeforeAmount"/> | ||||
| <result column="card_remain_real_amount" jdbcType="INTEGER" property="cardRemainRealAmount"/> | <result column="card_remain_real_amount" jdbcType="INTEGER" property="cardRemainRealAmount"/> | ||||
| @@ -25,7 +26,7 @@ | |||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`parent_tenant_id`,`card_id`,`owner_id`,`merchant_id`,`order_id`,`pos_order_id`, | `id`,`tenant_id`,`parent_tenant_id`,`card_id`,`owner_id`,`merchant_id`,`order_id`,`pos_order_id`, | ||||
| `deduction_amount`,`payment`,`real_payment`, `card_remain_amount`, | |||||
| `deduction_amount`,`payment`,`real_payment`,`subsidy`, `card_remain_amount`, | |||||
| `card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`, | `card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`, | ||||
| `create_date`, `update_date`, `pay_status`, `pay_from` | `create_date`, `update_date`, `pay_status`, `pay_from` | ||||
| </sql> | </sql> | ||||
| @@ -256,6 +257,17 @@ | |||||
| </if> | </if> | ||||
| group by cs.merchant_id | group by cs.merchant_id | ||||
| </select> | </select> | ||||
| <select id="sumMerchant" parameterType="com.iformall.domain.po.WxCardSpend" resultType="hashmap"> | |||||
| select cs.merchant_id | |||||
| IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount, | |||||
| IFNULL(SUM(cs.`payment`),0) as sum_payment, | |||||
| IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment, | |||||
| IFNULL(SUM(cs.`subsidy`),0) as sum_subsidy | |||||
| from wx_card_spend cs | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| group by cs.merchant_id | |||||
| </select> | |||||
| <select id="getMerchantIdList" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="Long"> | <select id="getMerchantIdList" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="Long"> | ||||
| select distinct cs.merchant_id | select distinct cs.merchant_id | ||||
| @@ -267,7 +279,8 @@ | |||||
| select | select | ||||
| IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount, | IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount, | ||||
| IFNULL(SUM(cs.`payment`),0) as sum_payment, | IFNULL(SUM(cs.`payment`),0) as sum_payment, | ||||
| IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment | |||||
| IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment, | |||||
| IFNULL(SUM(cs.`subsidy`),0) as sum_subsidy | |||||
| from wx_card_spend cs | from wx_card_spend cs | ||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||