| @@ -1,15 +1,18 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||
| import java.util.stream.Collectors; | |||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.domain.po.WxMiniappThemeValue; | import com.iformall.domain.po.WxMiniappThemeValue; | ||||
| import com.iformall.enums.EnumCouponType; | import com.iformall.enums.EnumCouponType; | ||||
| import com.iformall.enums.EnumMerchantStatus; | |||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| import org.apache.commons.beanutils.BeanUtils; | import org.apache.commons.beanutils.BeanUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -23,6 +26,7 @@ import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| @@ -34,7 +38,9 @@ import com.iformall.enums.EnumCouponChannelType; | |||||
| import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
| import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
| import com.iformall.service.WxMerchantService; | import com.iformall.service.WxMerchantService; | ||||
| import com.iformall.service.util.CouponCacheUtils; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.RedisCacheUtils; | |||||
| import com.iformall.utils.RedisLock; | import com.iformall.utils.RedisLock; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| @@ -58,6 +64,170 @@ public class WxCouponController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| @Qualifier("couponDetailRedisTemplate") | @Qualifier("couponDetailRedisTemplate") | ||||
| RedisTemplate<String, WxCouponCVo> cdRedisTemplate; | RedisTemplate<String, WxCouponCVo> cdRedisTemplate; | ||||
| @Autowired | |||||
| @Qualifier("objectCommonRedisTemplate") | |||||
| RedisTemplate<String, Object> redisTemplate; | |||||
| @ApiOperation("根据id(couponChannel)查询详情接口") | |||||
| @GetMapping("/couponDetail") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData couponDetail(String couponChannelId) { | |||||
| if ((StringUtils.isBlank(couponChannelId) || couponChannelId.equalsIgnoreCase(Constant.UNDEFINED)) | |||||
| ) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | |||||
| } | |||||
| Long couponChannelIdL = 0L; | |||||
| try { | |||||
| if (StringUtils.isNotBlank(couponChannelId) && !couponChannelId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
| couponChannelIdL = Long.valueOf(couponChannelId); | |||||
| } | |||||
| } catch (NumberFormatException e) { | |||||
| logger.error("id转换失败" + couponChannelId); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + couponChannelId); | |||||
| } | |||||
| if(couponChannelIdL <= 0){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | |||||
| } | |||||
| WxCouponChannel couponChannel = CouponCacheUtils.getCouponChannelCache(redisTemplate, couponChannelIdL); | |||||
| if (null == couponChannel) { | |||||
| couponChannel = wxCouponChannelService.getById(couponChannelIdL,this.getTenantInfo().getTenantId()); | |||||
| if (null == couponChannel) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId无效" + couponChannelId); | |||||
| } | |||||
| CouponCacheUtils.setCouponChannelCache(redisTemplate, couponChannelIdL, couponChannel); | |||||
| } | |||||
| WxCoupon coupon = CouponCacheUtils.getCouponCache(redisTemplate, couponChannel.getCouponId()); | |||||
| if (null == coupon) { | |||||
| coupon = couponService.getById(couponChannel.getCouponId(),couponChannel.getTenantId()); | |||||
| if (null == coupon) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannel找不到coupon" + couponChannelId); | |||||
| } | |||||
| if(EnumCouponType.COUPON_GIFT.getCode().equals(coupon.getType())){ | |||||
| WxCoupon couponQ = new WxCoupon(); | |||||
| couponQ.updateTenantInfo(coupon); | |||||
| List<Long> longs = JSON.parseArray(coupon.getGiftList(), Long.class); | |||||
| if(longs != null && longs.size() > 0){ | |||||
| couponQ.setIds(longs); | |||||
| coupon.setGiftCouponList(couponService.list(couponQ)); | |||||
| } | |||||
| } | |||||
| coupon.setCouponId(coupon.getId()); | |||||
| coupon.setCouponChannelId(couponChannel.getId()); | |||||
| CouponCacheUtils.setCouponCache(redisTemplate, couponChannel.getCouponId(), coupon); | |||||
| } | |||||
| updateActivityStatus(coupon,couponChannel); | |||||
| coupon.setCouponChannel(couponChannel); | |||||
| return new ResultData(coupon); | |||||
| } | |||||
| @ApiOperation("根据id(couponChannel)查询库存价格接口") | |||||
| @GetMapping("/couponPriceAndStock") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData couponPriceAndStock(String couponChannelId) { | |||||
| if ((StringUtils.isBlank(couponChannelId) || couponChannelId.equalsIgnoreCase(Constant.UNDEFINED)) | |||||
| ) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | |||||
| } | |||||
| Long couponChannelIdL = 0L; | |||||
| try { | |||||
| if (StringUtils.isNotBlank(couponChannelId) && !couponChannelId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
| couponChannelIdL = Long.valueOf(couponChannelId); | |||||
| } | |||||
| } catch (NumberFormatException e) { | |||||
| logger.error("id转换失败" + couponChannelId); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + couponChannelId); | |||||
| } | |||||
| if(couponChannelIdL <= 0){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | |||||
| } | |||||
| WxCouponChannel channelPriceAndStock = wxCouponChannelService.getPriceAndStock(this.getTenantInfo(), couponChannelIdL); | |||||
| if (null == channelPriceAndStock) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId非法"); | |||||
| } | |||||
| WxCoupon coupon = couponService.getPriceAndStock(channelPriceAndStock.getCouponId(),this.getTenantInfo().getTenantId()); | |||||
| if (null == coupon) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId查询不到coupon"); | |||||
| } | |||||
| StringBuffer sb = new StringBuffer("{\"salePrice\":"); | |||||
| if (null != channelPriceAndStock.getChannelPrice()) { | |||||
| sb.append(channelPriceAndStock.getChannelPrice()); | |||||
| }else { | |||||
| sb.append(coupon.getSalePrice()); | |||||
| } | |||||
| sb.append(",\"remainInventory\":"); | |||||
| if (null != channelPriceAndStock.getChannelStock()) { | |||||
| sb.append(channelPriceAndStock.getChannelStock()); | |||||
| }else { | |||||
| sb.append(coupon.getRemainInventory()); | |||||
| } | |||||
| sb.append(",\"inventory\":").append(coupon.getInventory()).append(",\"price\":").append(coupon.getPrice()).append(",\"creditPrice\":").append(coupon.getCreditPrice()).append("}"); | |||||
| return new ResultData(sb.toString()); | |||||
| } | |||||
| @ApiOperation("根据id(couponChannel)查询商品商户接口") | |||||
| @GetMapping("/couponMerchant") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData couponMerchant(String couponChannelId) { | |||||
| if ((StringUtils.isBlank(couponChannelId) || couponChannelId.equalsIgnoreCase(Constant.UNDEFINED)) | |||||
| ) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | |||||
| } | |||||
| Long couponChannelIdL = 0L; | |||||
| try { | |||||
| if (StringUtils.isNotBlank(couponChannelId) && !couponChannelId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
| couponChannelIdL = Long.valueOf(couponChannelId); | |||||
| } | |||||
| } catch (NumberFormatException e) { | |||||
| logger.error("id转换失败" + couponChannelId); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + couponChannelId); | |||||
| } | |||||
| if(couponChannelIdL <= 0){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | |||||
| } | |||||
| WxCouponChannel couponChannel = CouponCacheUtils.getCouponChannelCache(redisTemplate, couponChannelIdL); | |||||
| if (null == couponChannel) { | |||||
| couponChannel = wxCouponChannelService.getById(couponChannelIdL,this.getTenantInfo().getTenantId()); | |||||
| if (null == couponChannel) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId无效" + couponChannelId); | |||||
| } | |||||
| CouponCacheUtils.setCouponChannelCache(redisTemplate, couponChannelIdL, couponChannel); | |||||
| } | |||||
| List<WxMerchantVo> volist = CouponCacheUtils.getCouponMerchantCache(redisTemplate, couponChannel.getId()); | |||||
| if (null == volist) { | |||||
| List<Long> couponIdList = new ArrayList<Long>(); | |||||
| couponIdList.add(couponChannel.getCouponId()); | |||||
| Map<Long, List<WxMerchantVo>> couponMerchantVoMap = merchantService.findCouponMerchantVoList(couponIdList, couponChannel,true); | |||||
| volist = couponMerchantVoMap.get(couponChannel.getCouponId()); | |||||
| if (volist != null) { | |||||
| volist = volist.stream().filter( | |||||
| m->m.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())) | |||||
| .collect(Collectors.toList()); | |||||
| } | |||||
| if (null != volist && volist.size() > 0 ) { | |||||
| CouponCacheUtils.setCouponMerchantCache(redisTemplate, couponChannel.getCouponId(), volist); | |||||
| } | |||||
| } | |||||
| return new ResultData(volist); | |||||
| } | |||||
| @Autowired | @Autowired | ||||
| @Qualifier("objectCommonRedisTemplate") | @Qualifier("objectCommonRedisTemplate") | ||||
| @@ -339,5 +509,21 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| private void updateActivityStatus(WxCoupon coupon,WxCouponChannel couponChannel) { | |||||
| if (coupon.getType().equals(EnumCouponType.COUPON_PREORDER.getCode()) || | |||||
| (couponChannel.getTargetAd() != null && couponChannel.getTargetAd().equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())) | |||||
| ) { | |||||
| Date now = new Date(); | |||||
| if (couponChannel.getBeginTime().getTime() > now.getTime()) { | |||||
| coupon.setActStatus(EnumCouponChannelActivityStatus.PREPARED.getCode()); | |||||
| } else if (couponChannel.getEndTime().getTime() < now.getTime()) { | |||||
| coupon.setActStatus(EnumCouponChannelActivityStatus.ENDED.getCode()); | |||||
| } else { | |||||
| coupon.setActStatus(EnumCouponChannelActivityStatus.STARTED.getCode()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -215,6 +215,8 @@ public class WxCoupon extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @io.swagger.annotations.ApiModelProperty(value="投放渠道id",name="couponChannelId") | @io.swagger.annotations.ApiModelProperty(value="投放渠道id",name="couponChannelId") | ||||
| private Long couponChannelId; | private Long couponChannelId; | ||||
| @TableField(exist = false) | |||||
| private WxCouponChannel couponChannel; | |||||
| //营销分析 | //营销分析 | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @@ -239,6 +241,10 @@ public class WxCoupon extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<WxCoupon> giftCouponList; | private List<WxCoupon> giftCouponList; | ||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value = "现时抢购状态", name = "actStatus") | |||||
| private Integer actStatus; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @SortColumn(column = "press_count") | @SortColumn(column = "press_count") | ||||
| @@ -174,17 +174,8 @@ public class WxCouponChannelVo extends WxCouponChannel implements Serializable { | |||||
| */ | */ | ||||
| public void setWxCoupon(WxCoupon c){ | public void setWxCoupon(WxCoupon c){ | ||||
| if(c != null){ | if(c != null){ | ||||
| if(this.getChannelStock() == null){ | |||||
| this.setRemainInventory(c.getRemainInventory()); | |||||
| }else{ | |||||
| this.setRemainInventory(this.getChannelStock()); | |||||
| } | |||||
| if(this.getChannelPrice() == null){ | |||||
| this.setSalePrice(c.getSalePrice()); | |||||
| }else{ | |||||
| this.setSalePrice(this.getChannelPrice()); | |||||
| } | |||||
| this.setRemainInventory(c.getRemainInventory()); | |||||
| this.setSalePrice(c.getSalePrice()); | |||||
| this.setInventory(c.getInventory()); | this.setInventory(c.getInventory()); | ||||
| this.setCoverImg(c.getCoverImg()); | this.setCoverImg(c.getCoverImg()); | ||||
| this.setSubTitle(c.getSubTitle()); | this.setSubTitle(c.getSubTitle()); | ||||
| @@ -3,6 +3,7 @@ package com.iformall.mapper; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxTopic; | import com.iformall.domain.po.WxTopic; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||
| @@ -65,5 +66,7 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||||
| Integer clearChannelStock(@Param("id")Long id,@Param("tenantId")String tenantId); | Integer clearChannelStock(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| Integer setChannelPrice(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("price")Integer price); | Integer setChannelPrice(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("price")Integer price); | ||||
| WxCouponChannel getPriceAndStock(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| } | } | ||||
| @@ -30,6 +30,8 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> { | |||||
| List<Long> findSendCouponIds(@Param("expired")Integer expired,@Param("tenantId")String tenantId); | List<Long> findSendCouponIds(@Param("expired")Integer expired,@Param("tenantId")String tenantId); | ||||
| WxCoupon selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | WxCoupon selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| WxCoupon getPriceAndStock(@Param("id")Long id,@Param("tenantId")String tenantId); | |||||
| WxCouponCVo findVoDetail(@Param("id")Long id,@Param("tenantId")String tenantId); | WxCouponCVo findVoDetail(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| WxCouponCVo findVoStatusDetail(@Param("id")Long id,@Param("tenantId")String tenantId); | WxCouponCVo findVoStatusDetail(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| @@ -21,6 +21,8 @@ public class WxProfitSharing { | |||||
| private static final String RPOFIT_SHARING_ADD_RECEIVER_URL = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver"; | private static final String RPOFIT_SHARING_ADD_RECEIVER_URL = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver"; | ||||
| // 删除分账账户 | // 删除分账账户 | ||||
| private static final String RPOFIT_SHARING_REMOVE_RECEIVER_URL = "https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver"; | private static final String RPOFIT_SHARING_REMOVE_RECEIVER_URL = "https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver"; | ||||
| //查询订单待分账金额 | |||||
| private static final String RPOFIT_SHARING_ORDER_SHAREMENT_URL = "https://api.mch.weixin.qq.com/pay/profitsharingorderamountquery"; | |||||
| private WxProfitSharing() { | private WxProfitSharing() { | ||||
| @@ -69,6 +71,16 @@ public class WxProfitSharing { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| public static String addReceiver(Map<String, String> params) {return doPost(RPOFIT_SHARING_ADD_RECEIVER_URL, params); } | public static String addReceiver(Map<String, String> params) {return doPost(RPOFIT_SHARING_ADD_RECEIVER_URL, params); } | ||||
| /** | |||||
| * 查询订单待分账金额 | |||||
| * @param params | |||||
| * @return | |||||
| */ | |||||
| public static String queryOrderShareAmount(Map<String, String> params) { | |||||
| return doPost(RPOFIT_SHARING_ORDER_SHAREMENT_URL, params); | |||||
| } | |||||
| /** | /** | ||||
| * 分账接收方删除 | * 分账接收方删除 | ||||
| @@ -67,6 +67,7 @@ public interface WxCouponChannelService { | |||||
| void setChannelStock(WxCouponChannel record,Integer number); | void setChannelStock(WxCouponChannel record,Integer number); | ||||
| void releaseChannelStock(WxCouponChannel record); | void releaseChannelStock(WxCouponChannel record); | ||||
| void setChannelPrice(WxCouponChannel record); | void setChannelPrice(WxCouponChannel record); | ||||
| WxCouponChannel getPriceAndStock(TenantEntity tenantEntity,Long couponChannelId); | |||||
| ResultData getCouponChannelPoi(TenantEntity tenantInfo, Long id); | ResultData getCouponChannelPoi(TenantEntity tenantInfo, Long id); | ||||
| } | } | ||||
| @@ -17,6 +17,8 @@ public interface WxCouponService { | |||||
| ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize); | ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize); | ||||
| List<WxCoupon> list(WxCoupon wxCoupon); | |||||
| /** | /** | ||||
| * 根据实体查询分页列表 | * 根据实体查询分页列表 | ||||
| @@ -67,6 +69,8 @@ public interface WxCouponService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| WxCoupon getById(Long id,String tenantId); | WxCoupon getById(Long id,String tenantId); | ||||
| WxCoupon getPriceAndStock(Long id,String tenantId); | |||||
| WxCoupon getHtmlById(Long id,String tenantId); | WxCoupon getHtmlById(Long id,String tenantId); | ||||
| @@ -740,5 +740,10 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| return new ResultData(ErrorCode.SYS_NULLPOINTER_ERROR.getCode(),"未找到可用的数据"); | return new ResultData(ErrorCode.SYS_NULLPOINTER_ERROR.getCode(),"未找到可用的数据"); | ||||
| } | } | ||||
| @Override | |||||
| public WxCouponChannel getPriceAndStock(TenantEntity tenantEntity, Long couponChannelId) { | |||||
| return wxCouponChannelMapper.getPriceAndStock(couponChannelId, tenantEntity.getTenantId()); | |||||
| } | |||||
| } | } | ||||
| @@ -189,6 +189,11 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } | } | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @Override | |||||
| public List<WxCoupon> list(WxCoupon wxCoupon){ | |||||
| return wxCouponMapper.findList(wxCoupon); | |||||
| } | |||||
| @Override | @Override | ||||
| public PageInfo<WxCoupon> listAsPage(WxCoupon record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCoupon> listAsPage(WxCoupon record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -230,6 +235,11 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| public WxCoupon getById(Long id,String tenantId) { | public WxCoupon getById(Long id,String tenantId) { | ||||
| return wxCouponMapper.selectById(id,tenantId); | return wxCouponMapper.selectById(id,tenantId); | ||||
| } | } | ||||
| @Override | |||||
| public WxCoupon getPriceAndStock(Long id,String tenantId) { | |||||
| return wxCouponMapper.getPriceAndStock(id,tenantId); | |||||
| } | |||||
| @Override | @Override | ||||
| public WxCoupon getHtmlById(Long id,String tenantId) { | public WxCoupon getHtmlById(Long id,String tenantId) { | ||||
| @@ -429,5 +429,50 @@ public class WxPayShareService extends PayShareBaseAdapterService{ | |||||
| return new ShareAccountResult(true, null, "success", returnMap); | return new ShareAccountResult(true, null, "success", returnMap); | ||||
| } | } | ||||
| private static String queryOrderShareAmount(String mchId,String transcationId,String apiKey) { | |||||
| WxProfitSharingP psCmd = new WxProfitSharingP(); | |||||
| psCmd.setMch_id(mchId);//服务商商户id | |||||
| psCmd.setNonce_str(Utility.generate32UUID()); | |||||
| psCmd.setTransaction_id(transcationId); | |||||
| psCmd.setSign_type("HMAC-SHA256"); | |||||
| try { | |||||
| psCmd.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(psCmd), apiKey)); | |||||
| return WxProfitSharing.queryOrderShareAmount(BeanUtils.toStringMap(psCmd)); | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| } | |||||
| return null; | |||||
| } | |||||
| // public static void main(String[] args) { | |||||
| // System.out.println(queryOrderShareAmount("1511925291","4200001516202205010431149938","XHZfpVA0NzoXgLEjsujctUTcyj8Zur2C")); | |||||
| // //System.out.println(test("1511925291", "1604439800", "wxed2f44705544b892", "4200001455202205127949391954", "XHZfpVA0NzoXgLEjsujctUTcyj8Zur2C", "684670745960046592", "D:\\apiclient_cert.p12")); | |||||
| // } | |||||
| // | |||||
| // private static String test(String mchId,String subMchId,String parentAppId,String transcationId,String apiKey,String orderNo,String certPaht) { | |||||
| // WxProfitSharingFinishP psFCmd = new WxProfitSharingFinishP(); | |||||
| // psFCmd.setMch_id(mchId); | |||||
| // psFCmd.setSub_mch_id(subMchId); | |||||
| // psFCmd.setAppid(parentAppId); | |||||
| // psFCmd.setNonce_str(Utility.generate32UUID()); | |||||
| // psFCmd.setTransaction_id(transcationId); | |||||
| // psFCmd.setOut_order_no(orderNo); | |||||
| // //psFCmd.setAmount(amount); | |||||
| // psFCmd.setDescription("分账已完结"); | |||||
| // psFCmd.setSign_type("HMAC-SHA256"); | |||||
| // | |||||
| // String response; | |||||
| // try { | |||||
| // psFCmd.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(psFCmd), apiKey)); | |||||
| // log.info("request:" + psFCmd.toString()); | |||||
| // response = WxProfitSharing.finishOrder(BeanUtils.toStringMap(psFCmd), certPaht, mchId); | |||||
| // return response; | |||||
| // } catch (Exception e) { | |||||
| // e.printStackTrace(); | |||||
| // } | |||||
| // return null; | |||||
| // | |||||
| // } | |||||
| } | } | ||||
| @@ -0,0 +1,60 @@ | |||||
| package com.iformall.service.util; | |||||
| import java.util.List; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.WxCouponChannel; | |||||
| import com.iformall.domain.vo.WxMerchantVo; | |||||
| import com.iformall.utils.RedisCacheUtils; | |||||
| public class CouponCacheUtils { | |||||
| public static void removeCouponChannelCache(RedisTemplate<String, Object> template,Long couponChannelId) { | |||||
| String key = "couponChannelDetail:"+couponChannelId; | |||||
| RedisCacheUtils.removeCache(template, key); | |||||
| } | |||||
| public static void setCouponChannelCache(RedisTemplate<String, Object> template,Long couponChannelId,WxCouponChannel couponChannel) { | |||||
| String key = "couponChannelDetail:"+couponChannelId; | |||||
| RedisCacheUtils.cache(template, key, couponChannel, 24*3600); | |||||
| } | |||||
| public static WxCouponChannel getCouponChannelCache(RedisTemplate<String, Object> template,Long couponChannelId) { | |||||
| String key = "couponChannelDetail:"+couponChannelId; | |||||
| return RedisCacheUtils.getCacheObject(template, key,WxCouponChannel.class); | |||||
| } | |||||
| public static void removeCouponCache(RedisTemplate<String, Object> template,Long couponId) { | |||||
| String key = "couponDetail:"+couponId; | |||||
| RedisCacheUtils.removeCache(template, key); | |||||
| } | |||||
| public static void setCouponCache(RedisTemplate<String, Object> template,Long couponId,WxCoupon coupon) { | |||||
| String key = "couponDetail:"+couponId; | |||||
| RedisCacheUtils.cache(template, key, coupon, 24*3600); | |||||
| } | |||||
| public static WxCoupon getCouponCache(RedisTemplate<String, Object> template,Long couponId) { | |||||
| String key = "couponDetail:"+couponId; | |||||
| return RedisCacheUtils.getCacheObject(template, key,WxCoupon.class); | |||||
| } | |||||
| public static void removeCouponMerchantCache(RedisTemplate<String, Object> template,Long couponId) { | |||||
| String key = "couponMerchant:"+couponId; | |||||
| RedisCacheUtils.removeCache(template, key); | |||||
| } | |||||
| public static void setCouponMerchantCache(RedisTemplate<String, Object> template,Long couponId,List<WxMerchantVo> merchantList) { | |||||
| String key = "couponMerchant:"+couponId; | |||||
| RedisCacheUtils.cache(template, key, merchantList, 24*3600); | |||||
| } | |||||
| public static List<WxMerchantVo> getCouponMerchantCache(RedisTemplate<String, Object> template,Long couponId) { | |||||
| String key = "couponMerchant:"+couponId; | |||||
| return RedisCacheUtils.getCacheListObject(template, key,WxMerchantVo.class); | |||||
| } | |||||
| } | |||||
| @@ -356,5 +356,9 @@ | |||||
| <update id="setChannelPrice"> | <update id="setChannelPrice"> | ||||
| update wx_coupon_channel SET channel_price = #{price} where id = #{id} and tenant_id =#{tenantId} | update wx_coupon_channel SET channel_price = #{price} where id = #{id} and tenant_id =#{tenantId} | ||||
| </update> | </update> | ||||
| <select id="getPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select id,coupon_id,channel_stock,channel_price from wx_coupon_channel where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -325,6 +325,10 @@ | |||||
| select <include refid="allColumns"/> ,c.html from wx_coupon c where id = #{id} and tenant_id = #{tenantId} | select <include refid="allColumns"/> ,c.html from wx_coupon c where id = #{id} and tenant_id = #{tenantId} | ||||
| </select> | </select> | ||||
| <select id="getPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select c.sale_price,c.price,c.remain_inventory,c.inventory,c.credit_price from wx_coupon c where id = #{id} and tenant_id = #{tenantId} | |||||
| </select> | |||||
| <select id="findTenantSimpleList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap"> | <select id="findTenantSimpleList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap"> | ||||
| select id,title,sale_price,use_price,price,tail_price,orig_price,auto_refund,business,subsidy_type,source_type,type,unit,cover_img, | select id,title,sale_price,use_price,price,tail_price,orig_price,auto_refund,business,subsidy_type,source_type,type,unit,cover_img, | ||||
| sub_title,item_group,valid_type,valid_start_date,valid_end_date,pick_start_date,pick_end_date | sub_title,item_group,valid_type,valid_start_date,valid_end_date,pick_start_date,pick_end_date | ||||