| @@ -133,8 +133,7 @@ public class WxCouponController extends BaseController { | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) | @ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) | ||||
| public ResultData couponPriceAndStock(String couponChannelId) { | public ResultData couponPriceAndStock(String couponChannelId) { | ||||
| if ((StringUtils.isBlank(couponChannelId) || couponChannelId.equalsIgnoreCase(Constant.UNDEFINED)) | |||||
| ) { | |||||
| if ((StringUtils.isBlank(couponChannelId) || couponChannelId.equalsIgnoreCase(Constant.UNDEFINED))) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | ||||
| } | } | ||||
| Long couponChannelIdL = 0L; | Long couponChannelIdL = 0L; | ||||
| @@ -177,6 +176,102 @@ public class WxCouponController extends BaseController { | |||||
| return new ResultData(sb.toString()); | return new ResultData(sb.toString()); | ||||
| } | } | ||||
| @ApiOperation("批量根据id(couponChannel)查询库存价格接口") | |||||
| @GetMapping("/batchCouponPriceAndStock") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "couponChannelIds", value = "couponChannelIds", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData batchCouponPriceAndStock(String couponChannelIds) { | |||||
| if ((StringUtils.isBlank(couponChannelIds) || couponChannelIds.equalsIgnoreCase(Constant.UNDEFINED))) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | |||||
| } | |||||
| String[] couponChannelSs = couponChannelIds.split(","); | |||||
| if (null == couponChannelSs || couponChannelSs.length <= 0 ) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | |||||
| } | |||||
| List<Long> ccids = new ArrayList<Long>();; | |||||
| for (int i = 0 ; i < couponChannelSs.length; i ++ ) { | |||||
| Long couponChannelIdL = 0L; | |||||
| String ccid = couponChannelSs[i]; | |||||
| try { | |||||
| if (StringUtils.isNotBlank(ccid) && !ccid.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
| couponChannelIdL = Long.valueOf(ccid); | |||||
| } | |||||
| } catch (NumberFormatException e) { | |||||
| logger.error("id转换失败" + ccid); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + ccid); | |||||
| } | |||||
| if(couponChannelIdL <= 0){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); | |||||
| } | |||||
| ccids.add(couponChannelIdL); | |||||
| } | |||||
| List<WxCouponChannel> channelPriceAndStock = wxCouponChannelService.getPriceAndStock(this.getTenantInfo(), ccids); | |||||
| if (null == channelPriceAndStock || channelPriceAndStock.size() <= 0 ) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId非法"); | |||||
| } | |||||
| List<Long> couponIds = new ArrayList<Long>(); | |||||
| List<Long> couponChannelList = new ArrayList<Long>(); | |||||
| Map<Long,WxCouponChannel> couponChannelMap = new HashMap<Long,WxCouponChannel>(); | |||||
| for (int i = 0 ; i < channelPriceAndStock.size() ; i ++ ) { | |||||
| WxCouponChannel cc = channelPriceAndStock.get(i); | |||||
| couponChannelList.add(cc.getId()); | |||||
| if (null != cc.getCouponId()) { | |||||
| couponIds.add(cc.getCouponId()); | |||||
| } | |||||
| couponChannelMap.put(cc.getId(), cc); | |||||
| } | |||||
| if (couponIds.size() <= 0 ) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId查询不到coupon"); | |||||
| } | |||||
| List<WxCoupon> couponList = couponService.getPriceAndStock(couponIds,this.getTenantInfo().getTenantId()); | |||||
| if (null == couponList) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId查询不到coupon"); | |||||
| } | |||||
| Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>(); | |||||
| for (int i = 0 ; i < couponList.size() ; i ++ ) { | |||||
| WxCoupon cc = couponList.get(i); | |||||
| couponMap.put(cc.getId(), cc); | |||||
| } | |||||
| StringBuffer sb = new StringBuffer("["); | |||||
| for (int i = 0 ; i < couponChannelList.size() ; i ++) { | |||||
| Long ccid = couponChannelList.get(i); | |||||
| WxCouponChannel cc = couponChannelMap.get(ccid); | |||||
| if (null != cc) { | |||||
| WxCoupon coupon = null; | |||||
| if (null != cc.getCouponId()) { | |||||
| coupon = couponMap.get(cc.getCouponId()); | |||||
| } | |||||
| if (null == coupon) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId查询不到coupon"); | |||||
| } | |||||
| sb.append("{\"salePrice\":"); | |||||
| if (null != cc.getChannelPrice()) { | |||||
| sb.append(cc.getChannelPrice()); | |||||
| }else { | |||||
| sb.append(coupon.getSalePrice()); | |||||
| } | |||||
| sb.append(",\"remainInventory\":"); | |||||
| if (null != cc.getChannelStock()) { | |||||
| sb.append(cc.getChannelStock()); | |||||
| }else { | |||||
| sb.append(coupon.getRemainInventory()); | |||||
| } | |||||
| sb.append(",\"inventory\":").append(coupon.getInventory()).append(",\"price\":").append(coupon.getPrice()).append(",\"creditPrice\":").append(coupon.getCreditPrice()).append("}"); | |||||
| } | |||||
| } | |||||
| sb.append("]"); | |||||
| return new ResultData(sb.toString()); | |||||
| } | |||||
| @ApiOperation("根据id(couponChannel)查询商品商户接口") | @ApiOperation("根据id(couponChannel)查询商品商户接口") | ||||
| @GetMapping("/couponMerchant") | @GetMapping("/couponMerchant") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -70,5 +70,6 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||||
| 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); | WxCouponChannel getPriceAndStock(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| List<WxCouponChannel> batGetPriceAndStock(@Param("ids")List<Long> ids,@Param("tenantId")String tenantId); | |||||
| } | } | ||||
| @@ -32,6 +32,7 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> { | |||||
| 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); | WxCoupon getPriceAndStock(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| List<WxCoupon> batchGetPriceAndStock(@Param("ids")List<Long> ids,@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); | ||||
| @@ -71,6 +71,7 @@ public interface WxCouponChannelService { | |||||
| void releaseChannelStock(WxCouponChannel record); | void releaseChannelStock(WxCouponChannel record); | ||||
| void setChannelPrice(WxCouponChannel record); | void setChannelPrice(WxCouponChannel record); | ||||
| WxCouponChannel getPriceAndStock(TenantEntity tenantEntity,Long couponChannelId); | WxCouponChannel getPriceAndStock(TenantEntity tenantEntity,Long couponChannelId); | ||||
| List<WxCouponChannel> getPriceAndStock(TenantEntity tenantEntity,List<Long> couponChannelIds); | |||||
| ResultData getCouponChannelPoi(TenantEntity tenantInfo, Long id); | ResultData getCouponChannelPoi(TenantEntity tenantInfo, Long id); | ||||
| } | } | ||||
| @@ -71,6 +71,7 @@ public interface WxCouponService { | |||||
| WxCoupon getById(Long id,String tenantId); | WxCoupon getById(Long id,String tenantId); | ||||
| WxCoupon getPriceAndStock(Long id,String tenantId); | WxCoupon getPriceAndStock(Long id,String tenantId); | ||||
| List<WxCoupon> getPriceAndStock(List<Long> id,String tenantId); | |||||
| WxCoupon getHtmlById(Long id,String tenantId); | WxCoupon getHtmlById(Long id,String tenantId); | ||||
| @@ -796,6 +796,11 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| public WxCouponChannel getPriceAndStock(TenantEntity tenantEntity, Long couponChannelId) { | public WxCouponChannel getPriceAndStock(TenantEntity tenantEntity, Long couponChannelId) { | ||||
| return wxCouponChannelMapper.getPriceAndStock(couponChannelId, tenantEntity.getTenantId()); | return wxCouponChannelMapper.getPriceAndStock(couponChannelId, tenantEntity.getTenantId()); | ||||
| } | } | ||||
| @Override | |||||
| public List<WxCouponChannel> getPriceAndStock(TenantEntity tenantEntity, List<Long> couponChannelIds) { | |||||
| return wxCouponChannelMapper.batGetPriceAndStock(couponChannelIds, tenantEntity.getTenantId()); | |||||
| } | |||||
| } | } | ||||
| @@ -241,6 +241,11 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return wxCouponMapper.getPriceAndStock(id,tenantId); | return wxCouponMapper.getPriceAndStock(id,tenantId); | ||||
| } | } | ||||
| @Override | |||||
| public List<WxCoupon> getPriceAndStock(List<Long> ids,String tenantId) { | |||||
| return wxCouponMapper.batchGetPriceAndStock(ids,tenantId); | |||||
| } | |||||
| @Override | @Override | ||||
| public WxCoupon getHtmlById(Long id,String tenantId) { | public WxCoupon getHtmlById(Long id,String tenantId) { | ||||
| return wxCouponMapper.selectById(id,tenantId); | return wxCouponMapper.selectById(id,tenantId); | ||||
| @@ -391,5 +391,13 @@ | |||||
| <select id="getPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | <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 id,coupon_id,channel_stock,channel_price from wx_coupon_channel where `id` = #{id} and `tenant_id` = #{tenantId} | ||||
| </select> | </select> | ||||
| <select id="batGetPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select id,coupon_id,channel_stock,channel_price from wx_coupon_channel where `tenant_id` = #{tenantId} | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -329,6 +329,14 @@ | |||||
| 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 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> | ||||
| <select id="batchGetPriceAndStock" 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 tenant_id = #{tenantId} | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </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 | ||||