| @@ -1,12 +1,16 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.common.SysConfigConstant; | import com.iformall.common.SysConfigConstant; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.vo.WxCardCVo; | |||||
| import com.iformall.domain.vo.WxCardSpendVo; | import com.iformall.domain.vo.WxCardSpendVo; | ||||
| import com.iformall.domain.vo.WxCouponOrderCVo; | import com.iformall.domain.vo.WxCouponOrderCVo; | ||||
| import com.iformall.enums.EnumCardInfoType; | import com.iformall.enums.EnumCardInfoType; | ||||
| import com.iformall.enums.EnumCouponOrderStatus; | |||||
| import com.iformall.enums.EnumYesOrNo; | import com.iformall.enums.EnumYesOrNo; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.pay.WxPayConstant; | import com.iformall.pay.WxPayConstant; | ||||
| @@ -24,9 +28,7 @@ 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.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| import java.util.*; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("/api/cardInfo") | @RequestMapping("/api/cardInfo") | ||||
| @@ -40,11 +42,49 @@ public class WxCardInfoController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxCouponPasswordService couponPasswordService; | private WxCouponPasswordService couponPasswordService; | ||||
| @Autowired | |||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
| @Autowired | @Autowired | ||||
| private SysConfigService sysConfigService; | private SysConfigService sysConfigService; | ||||
| @Autowired | @Autowired | ||||
| private WxCouponService wxCouponService; | private WxCouponService wxCouponService; | ||||
| @Autowired | |||||
| private WxCouponOrderService wxCouponOrderService; | |||||
| @ApiOperation("卡包分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||||
| }) | |||||
| public ResultData cardList(@ModelAttribute WxCardCVo cardCVo, Integer pageNum, Integer pageSize) { | |||||
| if(cardCVo == null || StringUtils.isBlank(cardCVo.getUserPhone())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), cardCVo.getUserPhone()); | |||||
| if(basicInfo == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该手机号未查询到用户"); | |||||
| } | |||||
| if(pageNum == null){ | |||||
| pageNum = 1; | |||||
| } | |||||
| if(pageSize == null){ | |||||
| pageNum = 5; | |||||
| } | |||||
| cardCVo.updateTenantInfo(getTenantInfo()); | |||||
| cardCVo.setOwnerId(basicInfo.getId()); | |||||
| cardCVo.setMerchantId(getLoginBUser().getMerchantId()); | |||||
| cardCVo.setCouponOrderStatus(EnumCouponOrderStatus.CARD_USING.getCode()); | |||||
| cardCVo.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||||
| return wxCouponOrderService.listCardVoAsPage(cardCVo, pageNum, pageSize); | |||||
| } | |||||
| @ApiOperation(value = "查询卡信息") | @ApiOperation(value = "查询卡信息") | ||||
| @GetMapping("detail") | @GetMapping("detail") | ||||
| @@ -59,6 +59,9 @@ public class WxCardCVo extends WxCouponOrder { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| protected String statusStr; | protected String statusStr; | ||||
| @TableField(exist = false) | |||||
| private String userPhone; | |||||
| private WxCardInfo wxCardInfo; | private WxCardInfo wxCardInfo; | ||||
| @@ -168,7 +168,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| // 4. 扣减计算 | // 4. 扣减计算 | ||||
| Double paymentD = 1.0 * cardInfo.getSaleAmount() * record.getDeductionAmount() / cardInfo.getAmount(); | Double paymentD = 1.0 * cardInfo.getSaleAmount() * record.getDeductionAmount() / cardInfo.getAmount(); | ||||
| Integer payment = paymentD.intValue(); | |||||
| Integer payment = paymentD.intValue();//实际金额 | |||||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRealRate(), false); | int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRealRate(), false); | ||||
| Integer real_payment = payment - iChargeFee; | Integer real_payment = payment - iChargeFee; | ||||
| Integer remain_real_pament = cardInfo.getRemainingShareFeeAmount() - real_payment; | Integer remain_real_pament = cardInfo.getRemainingShareFeeAmount() - real_payment; | ||||
| @@ -2313,6 +2313,16 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| @Override | @Override | ||||
| public ResultData listCardVoAsPage(WxCardCVo record, Integer pageIndex, Integer pageSize) { | public ResultData listCardVoAsPage(WxCardCVo record, Integer pageIndex, Integer pageSize) { | ||||
| if(record.getMerchantId() != null){ | |||||
| List<Long> merchantIds = new ArrayList<Long>(); | |||||
| merchantIds.add(record.getMerchantId()); | |||||
| List<Long> merchantCouponIds = wxCouponMerchantMapper.findMerchantProductIds(record.getTenantId(), merchantIds, null); | |||||
| if(merchantCouponIds == null || merchantCouponIds.isEmpty()){ | |||||
| record.setId(-999L); | |||||
| }else{ | |||||
| record.setCouponIds(merchantCouponIds); | |||||
| } | |||||
| } | |||||
| //List<WxCardCVo> cardTransList = wxCardTransferInfoMapper.findCardListOfCUser(record); | //List<WxCardCVo> cardTransList = wxCardTransferInfoMapper.findCardListOfCUser(record); | ||||
| PageInfo<WxCouponOrder> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findCardListOfCUser(record)); | PageInfo<WxCouponOrder> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findCardListOfCUser(record)); | ||||
| PageInfo<WxCardCVo> retPageInfo = new PageInfo<WxCardCVo>(); | PageInfo<WxCardCVo> retPageInfo = new PageInfo<WxCardCVo>(); | ||||
| @@ -236,10 +236,14 @@ | |||||
| <select id="listOpenId" parameterType="com.iformall.domain.po.tt.TtCUser" resultType="String"> | <select id="listOpenId" parameterType="com.iformall.domain.po.tt.TtCUser" resultType="String"> | ||||
| select open_id | select open_id | ||||
| from tt_c_user | from tt_c_user | ||||
| where `tenant_id` = #{tenantId} | |||||
| where user_id is not null | |||||
| and `tenant_id` = #{tenantId} | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and `parent_tenant_id` = #{parentTenantId} | and `parent_tenant_id` = #{parentTenantId} | ||||
| </if> | </if> | ||||
| <if test=" null == userIds "> | |||||
| and DATE_SUB(CURDATE(), INTERVAL 100 DAY) <= date(active_time) | |||||
| </if> | |||||
| <if test=" null != userIds "> | <if test=" null != userIds "> | ||||
| and user_id in | and user_id in | ||||
| <foreach collection="userIds" index="index" item="userIdItem" open="(" separator="," close=")"> | <foreach collection="userIds" index="index" item="userIdItem" open="(" separator="," close=")"> | ||||
| @@ -244,10 +244,14 @@ | |||||
| <select id="listOpenId" parameterType="com.iformall.domain.po.WxCUser" resultType="String"> | <select id="listOpenId" parameterType="com.iformall.domain.po.WxCUser" resultType="String"> | ||||
| select open_id | select open_id | ||||
| from wx_c_user | from wx_c_user | ||||
| where `tenant_id` = #{tenantId} | |||||
| where user_id is not null | |||||
| and `tenant_id` = #{tenantId} | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and `parent_tenant_id` = #{parentTenantId} | and `parent_tenant_id` = #{parentTenantId} | ||||
| </if> | </if> | ||||
| <if test=" null == userIds "> | |||||
| and DATE_SUB(CURDATE(), INTERVAL 100 DAY) <= date(active_time) | |||||
| </if> | |||||
| <if test=" null != userIds "> | <if test=" null != userIds "> | ||||
| and user_id in | and user_id in | ||||
| <foreach collection="userIds" index="index" item="userIdItem" open="(" separator="," close=")"> | <foreach collection="userIds" index="index" item="userIdItem" open="(" separator="," close=")"> | ||||
| @@ -1068,6 +1068,12 @@ | |||||
| #{sItem} | #{sItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| <if test=" null != couponIds"> | |||||
| and co.coupon_id in | |||||
| <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")"> | |||||
| #{couponIdItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| </select> | </select> | ||||