| @@ -90,7 +90,7 @@ public class WxCardPayController extends BaseController { | |||
| final PageInfo<WxCardVo> page = wxCardInfoService.listAsPage(wxCardVo, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("C端扫B端储值卡交易流水(消费记录 + 补贴)列表接口") | |||
| @GetMapping("cardSpendlist") | |||
| @ApiImplicitParams({ | |||
| @@ -14,6 +14,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponPassword; | |||
| import com.iformall.domain.vo.WxCardSpendVo; | |||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||
| import com.iformall.domain.vo.WxCouponPasswordVo; | |||
| import com.iformall.enums.EnumCouponPasswordStatus; | |||
| @@ -32,6 +33,8 @@ import java.io.BufferedInputStream; | |||
| import java.io.File; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.concurrent.TimeUnit; | |||
| @@ -132,6 +135,21 @@ public class WxCouponPasswordController extends BaseController { | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("卡密记录导出") | |||
| @GetMapping("/exportData") | |||
| @SystemControllerLog(description = "卡检索-卡密记录导出") | |||
| public void exportData(@ModelAttribute WxCouponPassword wxCouponPassword, HttpServletRequest request, HttpServletResponse response) { | |||
| wxCouponPassword.updateTenantInfo(getTenantInfo()); | |||
| wxCouponPassword.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| StringBuffer statussb = new StringBuffer(); | |||
| statussb.append(EnumCouponPasswordStatus.MSG_SENDED.getCode()).append(",") | |||
| .append(EnumCouponPasswordStatus.MSG_SENDING.getCode()).append(",") | |||
| .append(EnumCouponPasswordStatus.USED.getCode()).append(",") | |||
| .append(EnumCouponPasswordStatus.CANCEL.getCode()); | |||
| wxCouponPassword.setStatusStr(statussb.toString()); | |||
| wxCouponPasswordService.exportData(wxCouponPassword, request, response); | |||
| } | |||
| @ApiOperation("启用/停用") | |||
| @PostMapping("/startOrStop") | |||
| @SystemControllerLog(description = "启用/停用") | |||
| @@ -11,6 +11,7 @@ import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.vo.WxCardSpendVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.enums.EnumCardInfoStatus; | |||
| import com.iformall.enums.EnumCouponPasswordStatus; | |||
| import com.iformall.enums.EnumCouponStatus; | |||
| import com.iformall.enums.EnumCreditLockedStatus; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| @@ -197,6 +198,11 @@ public class WxCardPayController extends BaseController { | |||
| if (EnumYesOrNo.YES.getCode().intValue() == couponPassword.getIsStop().intValue()) { | |||
| return new ResultData(ErrorCode.CARD_IS_NOT_FOUND.getCode(),"卡已被禁用."); | |||
| } | |||
| if (EnumCouponPasswordStatus.CANCEL.getCode().intValue() == couponPassword.getStatus().intValue()) { | |||
| return new ResultData(ErrorCode.CARD_IS_NOT_FOUND.getCode(),"卡已作废."); | |||
| } | |||
| if (couponPassword.getPrice().intValue() <= 0 ) { | |||
| return new ResultData(ErrorCode.CARD_IS_NOT_FOUND.getCode(),"卡密面额未设置."); | |||
| } | |||
| @@ -205,10 +211,6 @@ public class WxCardPayController extends BaseController { | |||
| if (coupon == null) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| if (coupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { | |||
| logger.error("此券已作废:" + coupon.getId()); | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | |||
| } | |||
| //实体卡兑换后再次使用 | |||
| WxCardInfo cardInfo = wxCardInfoService.getByCouponPasswordId(couponPassword.getId(), coupon); | |||
| if (null == cardInfo) { | |||
| @@ -65,6 +65,26 @@ public class WxCouponPasswordController extends BaseController { | |||
| return getCouponOrderByPassword(password, formId,payCheck,payPassword, memberId,EnumPayWay.PAY_WAY_NOT_UNPAY_PASSWD,EnumPayVersion.NO_VERSION); | |||
| } | |||
| private WxCouponPassword getWxCouponPasswordQuery(String password) { | |||
| WxCouponPassword couponPasswordQ = new WxCouponPassword(); | |||
| couponPasswordQ.updateTenantInfo(getTenantInfo()); | |||
| boolean isCardId = false; | |||
| if (password.length() > 10) { | |||
| isCardId = true; | |||
| } | |||
| if (isCardId) { | |||
| try { | |||
| Long cardId = Long.parseLong(password); | |||
| couponPasswordQ.setId(cardId); | |||
| }catch (Exception e) { | |||
| return null; | |||
| } | |||
| }else { | |||
| couponPasswordQ.setPassword(password); | |||
| } | |||
| return couponPasswordQ; | |||
| } | |||
| private ResultData getCouponOrderByPassword(String password,String formId,String payCheck,String payPassword,Long memberId,EnumPayWay payWay,EnumPayVersion payVersion) { | |||
| password = StringUtils.trimToNull(password); | |||
| payPassword = StringUtils.trimToNull(payPassword); | |||
| @@ -89,23 +109,10 @@ public class WxCouponPasswordController extends BaseController { | |||
| } | |||
| } | |||
| boolean isCardId = false; | |||
| if (password.length() > 10) { | |||
| isCardId = true; | |||
| } | |||
| // 1. 根据password获取领取的couponId | |||
| WxCouponPassword couponPasswordQ = new WxCouponPassword(); | |||
| couponPasswordQ.updateTenantInfo(getTenantInfo()); | |||
| if (isCardId) { | |||
| try { | |||
| Long cardId = Long.parseLong(password); | |||
| couponPasswordQ.setId(cardId); | |||
| }catch (Exception e) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "password参数非法"); | |||
| } | |||
| }else { | |||
| couponPasswordQ.setPassword(password); | |||
| WxCouponPassword couponPasswordQ = getWxCouponPasswordQuery(password); | |||
| if (null == couponPasswordQ) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "卡号或者卡密错误"); | |||
| } | |||
| couponPasswordQ.setExpireDate(new Date()); | |||
| WxCouponPassword couponPassword = couponPasswordService.getByObj(couponPasswordQ); | |||
| @@ -209,24 +216,35 @@ public class WxCouponPasswordController extends BaseController { | |||
| @ApiImplicitParam(name = "cardId", value = "券ID", dataType = "String", paramType = "query", required = true) | |||
| }) | |||
| public ResultData getCardDetail(String cardId) { | |||
| cardId = StringUtils.trimToNull(cardId); | |||
| if (StringUtils.isBlank(cardId) || cardId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"参数错误."); | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"卡号或者卡密错误."); | |||
| } | |||
| cardId = StringUtils.trimToNull(cardId); | |||
| WxCouponPassword couponPasswordQ = getWxCouponPasswordQuery(cardId); | |||
| if (null == couponPasswordQ) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "卡号或者卡密错误"); | |||
| } | |||
| WxCouponPassword password = null; | |||
| try { | |||
| password = couponPasswordService.getById(Long.parseLong(cardId)); | |||
| password = couponPasswordService.getByObj(couponPasswordQ); | |||
| if (null == password) { | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"参数错误."); | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"卡号或者卡密错误."); | |||
| } | |||
| }catch(Exception e) { | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"参数错误."); | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"卡号或者卡密错误."); | |||
| } | |||
| if (password.getStatus().intValue() == EnumCouponPasswordStatus.CANCEL.getCode().intValue()) { | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"卡已作废."); | |||
| } | |||
| WxCoupon coupon = couponService.getById(password.getCouponId(),password.getTenantId()); | |||
| if (coupon == null) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| Long memberId = getMemberId(); | |||
| Map retMap = new HashMap(); | |||
| retMap.put("title", coupon.getTitle()); | |||
| retMap.put("couponPasswordId", password.getId()); | |||
| @@ -240,6 +258,11 @@ public class WxCouponPasswordController extends BaseController { | |||
| if (null != user) { | |||
| retMap.put("ownerPhone", user.getPhone()); | |||
| } | |||
| if (owner.equals(memberId)) { | |||
| retMap.put("owned", EnumYesOrNo.YES.getCode()); | |||
| }else { | |||
| retMap.put("owned", EnumYesOrNo.NO.getCode()); | |||
| } | |||
| } | |||
| retMap.put("remainAmount", cardInfo.getRemainingAmount()); | |||
| retMap.put("eCardId", cardInfo.getId()); | |||
| @@ -30,6 +30,6 @@ public interface WxCouponPasswordMapper extends CommonMapper<WxCouponPassword, L | |||
| void updateIsStop(@Param("tenantId")String tenantId,@Param("id")Long Id,@Param("isStop")Integer isStop); | |||
| void setPrice(WxCouponPassword wxCouponPassword); | |||
| Integer setPrice(WxCouponPassword wxCouponPassword); | |||
| } | |||
| @@ -5,6 +5,7 @@ import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxCouponPassword; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCardPriceTemplate; | |||
| import com.iformall.domain.vo.WxCardSpendVo; | |||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||
| import com.iformall.domain.vo.WxCouponPasswordVo; | |||
| @@ -26,6 +27,8 @@ public interface WxCouponPasswordService { | |||
| PageInfo<WxCouponPasswordVo> listVoAsPage(WxCouponPassword record, Integer pageIndex, Integer pageSize); | |||
| void exportData(WxCouponPassword wxCouponPassword, HttpServletRequest request, HttpServletResponse response); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| @@ -80,7 +83,7 @@ public interface WxCouponPasswordService { | |||
| void startOrStop(WxCouponPassword wxCouponPassword); | |||
| void setPrice(WxCouponPassword wxCouponPassword); | |||
| Integer setPrice(WxCouponPassword wxCouponPassword); | |||
| void exportTemplate(HttpServletRequest request, HttpServletResponse response); | |||
| void importPrice(MallUserInfo user,String importKey, WxCardPriceTemplate template); | |||
| @@ -11,6 +11,7 @@ import com.iformall.enums.EnumCouponPasswordStatus; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.domain.vo.WxCUserBasicInfoVo; | |||
| import com.iformall.domain.vo.WxCardPriceTemplate; | |||
| import com.iformall.domain.vo.WxCardSpendVo; | |||
| import com.iformall.domain.vo.WxCouponOrderBVo; | |||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||
| import com.iformall.domain.vo.WxCouponPasswordVo; | |||
| @@ -190,6 +191,12 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService { | |||
| return new ArrayList<WxCouponPasswordVo>(); | |||
| } | |||
| @Override | |||
| public void exportData(WxCouponPassword wxCouponPassword, HttpServletRequest request, HttpServletResponse response) { | |||
| PageInfo<WxCouponPasswordVo> pageInfo = this.listVoAsPage(wxCouponPassword, 1, 5000); | |||
| excelService.exportExcel(pageInfo.getList(), null, "卡密记录", WxCouponPasswordVo.class, "卡密记录.xlsx", response, false); | |||
| } | |||
| @Override | |||
| public WxCouponPassword getById(Long id) { | |||
| @@ -322,8 +329,8 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService { | |||
| } | |||
| @Override | |||
| public void setPrice(WxCouponPassword wxCouponPassword) { | |||
| wxCouponPasswordMapper.setPrice(wxCouponPassword); | |||
| public Integer setPrice(WxCouponPassword wxCouponPassword) { | |||
| return wxCouponPasswordMapper.setPrice(wxCouponPassword); | |||
| } | |||
| @Override | |||
| @@ -365,7 +372,12 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService { | |||
| password.updateTenantInfo(user); | |||
| password.setId(Long.parseLong(template.getCouponPasswordId())); | |||
| password.setPrice(new BigDecimal(template.getPrice()).multiply(new BigDecimal(100)).intValue()); | |||
| setPrice(password); | |||
| Integer count = setPrice(password); | |||
| if (null != count && count > 0 ) { | |||
| }else { | |||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||
| return ; | |||
| } | |||
| }catch(Exception e) { | |||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||
| logger.error("import price error.",e); | |||
| @@ -1796,7 +1796,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| //下架拼团券 | |||
| wxOrderService.updateOrderGroupStatusByCouponId(couponId, tenantInfo, EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode()); | |||
| // 卡下架后,转赠找不到卡相关信息,所以修改卡转赠状态为不可转赠 | |||
| wxCardInfoMapper.updateTransferStatusByCouponId(couponId); | |||
| //wxCardInfoMapper.updateTransferStatusByCouponId(couponId); | |||
| // 卡券下架,未使用的卡密要下架 | |||
| couponPasswordMapper.disableByCouponId(couponId); | |||