| @@ -118,6 +118,24 @@ public class WxProjectConfigController extends BaseController { | |||||
| // | // | ||||
| // } | // } | ||||
| @ApiOperation("查询商场集团列表") | |||||
| @GetMapping(value = "/childMallList") | |||||
| @SystemControllerLog(description = "商场基础数据") | |||||
| @TenantIgnore | |||||
| public ResultData childMallList(@ModelAttribute WxMall wxMall, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxProjectConfigController::getMallList"); | |||||
| try { | |||||
| if(wxMall == null){ | |||||
| wxMall = new WxMall(); | |||||
| } | |||||
| wxMall.setParentTenantId(this.getTenantInfo().getTenantId()); | |||||
| PageInfo<WxMall> page = wxMallService.listAsPage(wxMall, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| }catch (Exception e){ | |||||
| logger.error(e.getMessage(),e); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| @ApiOperation("查询商场集团列表") | @ApiOperation("查询商场集团列表") | ||||
| @GetMapping(value = "/mallList") | @GetMapping(value = "/mallList") | ||||
| @@ -84,8 +84,22 @@ public class WxCouponController extends BaseController { | |||||
| public ResultData parentCouponList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize,Boolean isList) { | public ResultData parentCouponList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize,Boolean isList) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::list"); | logger.debug("[" + getIpAddr() + "] WxCouponController::list"); | ||||
| if (wxCoupon == null) wxCoupon = new WxCoupon(); | if (wxCoupon == null) wxCoupon = new WxCoupon(); | ||||
| wxCoupon.setTenantId(getTenantInfo().getParentTenantId()); | |||||
| TenantEntity mallTenantEntity = getTenantInfo(); | |||||
| wxCoupon.setTenantId(mallTenantEntity.getParentTenantId()); | |||||
| wxCoupon.setParentTenantId(null); | wxCoupon.setParentTenantId(null); | ||||
| //平台券 | |||||
| if (EnumCouponType.COUPON_DOUYIN_PLAT.getCode() == wxCoupon.getType()) { | |||||
| //查询已经分配了的parentCouponList | |||||
| WxCouponMall couponMall = new WxCouponMall(); | |||||
| couponMall.updateTenantInfo(wxCoupon); | |||||
| couponMall.setMallTenantId(mallTenantEntity.getTenantId()); | |||||
| List<Long> couponIds = wxCouponMallService.listCouponIds(couponMall); | |||||
| if (null != couponIds && couponIds.size() > 0 ) { | |||||
| wxCoupon.setIds(couponIds); | |||||
| }else { | |||||
| wxCoupon.setId(-1L); | |||||
| } | |||||
| } | |||||
| return couponList(wxCoupon, pageNum, pageSize, isList); | return couponList(wxCoupon, pageNum, pageSize, isList); | ||||
| } | } | ||||
| @@ -407,7 +421,8 @@ public class WxCouponController extends BaseController { | |||||
| @SystemControllerLog(description = "券投放-查询") | @SystemControllerLog(description = "券投放-查询") | ||||
| public ResultData findById(@RequestParam Long id) { | public ResultData findById(@RequestParam Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | ||||
| return new ResultData(wxCouponService.getVoById(id,getTenantInfo().getTenantId())); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| return new ResultData(wxCouponService.getVoById(id,tenantEntity.getTenantId(),tenantEntity)); | |||||
| } | } | ||||
| @TenantIgnore | @TenantIgnore | ||||
| @@ -417,7 +432,8 @@ public class WxCouponController extends BaseController { | |||||
| @SystemControllerLog(description = "券投放-查询") | @SystemControllerLog(description = "券投放-查询") | ||||
| public ResultData findParentCouponById(@RequestParam Long id) { | public ResultData findParentCouponById(@RequestParam Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | ||||
| return new ResultData(wxCouponService.getVoById(id,getTenantInfo().getParentTenantId())); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| return new ResultData(wxCouponService.getVoById(id,getTenantInfo().getParentTenantId(),tenantEntity)); | |||||
| } | } | ||||
| @TenantIgnore | @TenantIgnore | ||||
| @@ -599,6 +615,7 @@ public class WxCouponController extends BaseController { | |||||
| return new ResultData(wxCouponMallService.list(wxCouponMall,true)); | return new ResultData(wxCouponMallService.list(wxCouponMall,true)); | ||||
| } | } | ||||
| @TenantIgnore | |||||
| @ApiOperation("平台券商场列表") | @ApiOperation("平台券商场列表") | ||||
| @GetMapping("/getCouponMall") | @GetMapping("/getCouponMall") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -636,6 +653,7 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| @TenantIgnore | |||||
| @ApiOperation("商场设置平台券商户") | @ApiOperation("商场设置平台券商户") | ||||
| @PostMapping("/setParentCouponMerchants") | @PostMapping("/setParentCouponMerchants") | ||||
| public ResultData setMallMerchants(@RequestBody WxCoupon wxCoupon) { | public ResultData setMallMerchants(@RequestBody WxCoupon wxCoupon) { | ||||
| @@ -676,6 +694,7 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| @TenantIgnore | |||||
| @ApiOperation("商场设置平台券已完成") | @ApiOperation("商场设置平台券已完成") | ||||
| @PostMapping("/setPlatCouponFinished") | @PostMapping("/setPlatCouponFinished") | ||||
| public ResultData setPlatCouponFinished(@RequestBody WxCoupon wxCoupon) { | public ResultData setPlatCouponFinished(@RequestBody WxCoupon wxCoupon) { | ||||
| @@ -694,7 +713,8 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| @ApiOperation("商场设置平台券已完成") | |||||
| @TenantIgnore | |||||
| @ApiOperation("商场设置平台券未完成") | |||||
| @PostMapping("/setPlatCouponUnFinished") | @PostMapping("/setPlatCouponUnFinished") | ||||
| public ResultData setPlatCouponUnFinished(@RequestBody WxCoupon wxCoupon) { | public ResultData setPlatCouponUnFinished(@RequestBody WxCoupon wxCoupon) { | ||||
| try { | try { | ||||
| @@ -383,7 +383,8 @@ public class WxCouponController extends BaseController { | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | ||||
| public ResultData findById(@RequestParam Long id) { | public ResultData findById(@RequestParam Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | ||||
| return new ResultData(wxCouponService.getVoById(id,getTenantInfo().getTenantId())); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| return new ResultData(wxCouponService.getVoById(id,tenantEntity.getTenantId(),tenantEntity)); | |||||
| } | } | ||||
| @@ -210,7 +210,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| } else { | } else { | ||||
| wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId(),wxMerchantBUser.getTenantId()); | |||||
| wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId(),wxMerchantBUser.getTenantId(),wxMerchantBUser); | |||||
| if (wxCouponCVo == null) { | if (wxCouponCVo == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -11,6 +11,7 @@ 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.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumCouponType; | import com.iformall.enums.EnumCouponType; | ||||
| import com.iformall.enums.EnumMerchantStatus; | import com.iformall.enums.EnumMerchantStatus; | ||||
| import com.iformall.utils.*; | import com.iformall.utils.*; | ||||
| @@ -72,12 +73,14 @@ public class WxCouponController extends BaseController { | |||||
| @ApiOperation("根据id(couponChannel)查询详情接口") | @ApiOperation("根据id(couponChannel)查询详情接口") | ||||
| @GetMapping("/couponDetail") | @GetMapping("/couponDetail") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) | |||||
| @ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "mallTenantId", value = "mallTenantId", dataType = "String", paramType = "query", required = false)}) | |||||
| public ResultData couponDetail(String couponChannelId) { | public ResultData couponDetail(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; | ||||
| try { | try { | ||||
| @@ -391,7 +394,8 @@ public class WxCouponController extends BaseController { | |||||
| //WxCouponCVo wxCouponCVo = wxCouponChannelService.findDetailVo(couponChannelIdL); | //WxCouponCVo wxCouponCVo = wxCouponChannelService.findDetailVo(couponChannelIdL); | ||||
| WxCouponCVo wxCouponCVo = null; | WxCouponCVo wxCouponCVo = null; | ||||
| try { | try { | ||||
| wxCouponCVo = generateWxCouponCVoex(couponChannelIdL,couponIdL,getTenantInfo().getTenantId()); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| wxCouponCVo = generateWxCouponCVoex(couponChannelIdL,couponIdL,tenantEntity.getTenantId(),tenantEntity); | |||||
| } catch (IllegalAccessException e) { | } catch (IllegalAccessException e) { | ||||
| logger.error("coupon detail fail,copyproperties error" + couponChannelId,e); | logger.error("coupon detail fail,copyproperties error" + couponChannelId,e); | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "coupon detail fail,copyproperties error" + couponChannelId); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "coupon detail fail,copyproperties error" + couponChannelId); | ||||
| @@ -527,13 +531,13 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| private WxCouponCVo generateWxCouponCVoex(Long couponChannelIdL,Long couponIdL,String tenantId) throws IllegalAccessException, InvocationTargetException { | |||||
| private WxCouponCVo generateWxCouponCVoex(Long couponChannelIdL,Long couponIdL,String couponTenantId,TenantEntity mallTenantEntity) throws IllegalAccessException, InvocationTargetException { | |||||
| if(couponChannelIdL > 0l){ | if(couponChannelIdL > 0l){ | ||||
| WxCouponChannel cc = wxCouponChannelService.getById(couponChannelIdL,tenantId); | |||||
| WxCouponChannel cc = wxCouponChannelService.getById(couponChannelIdL,couponTenantId); | |||||
| if(cc == null){ | if(cc == null){ | ||||
| return null; | return null; | ||||
| } | } | ||||
| WxCouponCVo wxcv = couponService.getVoById(cc.getCouponId(),tenantId); | |||||
| WxCouponCVo wxcv = couponService.getVoById(cc.getCouponId(),couponTenantId,mallTenantEntity); | |||||
| if(wxcv == null){ | if(wxcv == null){ | ||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -552,7 +556,7 @@ public class WxCouponController extends BaseController { | |||||
| wxcv.setTtSpuId(cc.getTtSpuId()); | wxcv.setTtSpuId(cc.getTtSpuId()); | ||||
| return wxcv; | return wxcv; | ||||
| }else if(couponIdL > 0l){ | }else if(couponIdL > 0l){ | ||||
| WxCouponCVo wxcv = couponService.getVoById(couponIdL,tenantId); | |||||
| WxCouponCVo wxcv = couponService.getVoById(couponIdL,couponTenantId,mallTenantEntity); | |||||
| return wxcv; | return wxcv; | ||||
| } | } | ||||
| return null; | return null; | ||||
| @@ -119,7 +119,8 @@ public class WxCouponOrderController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | ||||
| } | } | ||||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId,getTenantInfo()); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId,tenantEntity); | |||||
| if (wxCouponOrderCVo == null) { | if (wxCouponOrderCVo == null) { | ||||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| } | } | ||||
| @@ -144,7 +145,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| } else { | } else { | ||||
| wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId(),wxCouponOrderCVo.getTenantId()); | |||||
| wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId(),wxCouponOrderCVo.getTenantId(),tenantEntity); | |||||
| if (wxCouponCVo == null) { | if (wxCouponCVo == null) { | ||||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | return new ResultData(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxOrder; | import com.iformall.domain.po.WxOrder; | ||||
| import com.iformall.domain.po.WxOrderPress; | import com.iformall.domain.po.WxOrderPress; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.enums.EnumOrderPressStatus; | import com.iformall.enums.EnumOrderPressStatus; | ||||
| import com.iformall.enums.EnumOrderStatus; | import com.iformall.enums.EnumOrderStatus; | ||||
| @@ -91,12 +92,15 @@ public class WxPressOrderController extends BaseController { | |||||
| ValueOperations<String, WxOrder> operations = orderRedisTemplate.opsForValue(); | ValueOperations<String, WxOrder> operations = orderRedisTemplate.opsForValue(); | ||||
| // 缓存 | // 缓存 | ||||
| boolean hasKey = orderRedisTemplate.hasKey(key); | boolean hasKey = orderRedisTemplate.hasKey(key); | ||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| if (hasKey) { | if (hasKey) { | ||||
| // 从缓存获取砍价订单信息 | // 从缓存获取砍价订单信息 | ||||
| order = operations.get(key); | order = operations.get(key); | ||||
| } else { | } else { | ||||
| // 订单没有入缓存,需要从数据库中读取 | // 订单没有入缓存,需要从数据库中读取 | ||||
| order = wxOrderService.getById(orderId,getTenantInfo().getTenantId()); | |||||
| order = wxOrderService.getById(orderId,tenantEntity.getTenantId()); | |||||
| if (order != null) { | if (order != null) { | ||||
| // 订单优化,进缓存 | // 订单优化,进缓存 | ||||
| orderRedisTemplate.opsForValue().set(key, order, 3600, TimeUnit.SECONDS); | orderRedisTemplate.opsForValue().set(key, order, 3600, TimeUnit.SECONDS); | ||||
| @@ -117,7 +121,7 @@ public class WxPressOrderController extends BaseController { | |||||
| wxCouponCVo = cdOperations.get(cdKey); | wxCouponCVo = cdOperations.get(cdKey); | ||||
| } else { | } else { | ||||
| // 券信息没有入缓存,需要从数据库中读取 | // 券信息没有入缓存,需要从数据库中读取 | ||||
| wxCouponCVo = wxCouponService.getVoById(order.getProductId(),order.getTenantId()); | |||||
| wxCouponCVo = wxCouponService.getVoById(order.getProductId(),order.getTenantId(),tenantEntity); | |||||
| if (wxCouponCVo != null) { | if (wxCouponCVo != null) { | ||||
| // 券详情优化,进缓存 | // 券详情优化,进缓存 | ||||
| couponCVoRedisTemplate.opsForValue().set(cdKey, wxCouponCVo, 3600, TimeUnit.SECONDS); | couponCVoRedisTemplate.opsForValue().set(cdKey, wxCouponCVo, 3600, TimeUnit.SECONDS); | ||||
| @@ -63,15 +63,29 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| if(cUser == null || cUser.getExpireTime().getTime() < System.currentTimeMillis()){ | if(cUser == null || cUser.getExpireTime().getTime() < System.currentTimeMillis()){ | ||||
| throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); | throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); | ||||
| } | } | ||||
| //集团版中针对某一商场的业务需要传递mallTenantId | |||||
| String mallTenantId = request.getHeader("mallTenantId"); | |||||
| if(StringUtils.isBlank(mallTenantId)){ | |||||
| mallTenantId = request.getParameter("mallTenantId"); | |||||
| } | |||||
| //设置userId到request里,后续根据userId,获取用户信息 | //设置userId到request里,后续根据userId,获取用户信息 | ||||
| request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | ||||
| request.setAttribute(Constant.TENANT_ID, cUser.getTenantId()); | |||||
| if (!StringUtils.isBlank(mallTenantId)) { | |||||
| request.setAttribute(Constant.TENANT_ID, mallTenantId); | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, cUser.getTenantId()); | |||||
| }else { | |||||
| request.setAttribute(Constant.TENANT_ID, cUser.getTenantId()); | |||||
| if (StringUtils.isNotBlank(cUser.getParentTenantId())) { | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, cUser.getParentTenantId()); | |||||
| } | |||||
| } | |||||
| request.setAttribute(Constant.REQUEST_C_USER_KEY, cUser); | request.setAttribute(Constant.REQUEST_C_USER_KEY, cUser); | ||||
| request.setAttribute(Constant.APP_INFO,cUser.getAppinfo()); | request.setAttribute(Constant.APP_INFO,cUser.getAppinfo()); | ||||
| if (StringUtils.isNotBlank(cUser.getParentTenantId())) { | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, cUser.getParentTenantId()); | |||||
| } | |||||
| if(cUser.basicInfoIs()){ | if(cUser.basicInfoIs()){ | ||||
| request.setAttribute(Constant.LOGIN_MEMBER_KEY, cUser.getUserId()); | request.setAttribute(Constant.LOGIN_MEMBER_KEY, cUser.getUserId()); | ||||
| } | } | ||||
| @@ -86,7 +100,11 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| if(tenantIgnoreAnnotation != null){ | if(tenantIgnoreAnnotation != null){ | ||||
| TenantThreadLocal.remove(); | TenantThreadLocal.remove(); | ||||
| }else { | }else { | ||||
| TenantThreadLocal.setCurrentThreadTenant(cUser.getTenantId(), cUser.getParentTenantId()); | |||||
| if (!StringUtils.isBlank(mallTenantId)) { | |||||
| TenantThreadLocal.setCurrentThreadTenant(cUser.getTenantId(), cUser.getParentTenantId()); | |||||
| }else { | |||||
| TenantThreadLocal.setCurrentThreadTenant(mallTenantId, cUser.getTenantId()); | |||||
| } | |||||
| } | } | ||||
| return true; | return true; | ||||
| @@ -13,6 +13,7 @@ import org.apache.ibatis.annotations.Param; | |||||
| public interface WxCouponMallMapper extends CommonMapper<WxCouponMall, Long> { | public interface WxCouponMallMapper extends CommonMapper<WxCouponMall, Long> { | ||||
| List<WxCouponMall> findList(WxCouponMall wxCouponMall); | List<WxCouponMall> findList(WxCouponMall wxCouponMall); | ||||
| List<Long> findCouponIdList(WxCouponMall wxCouponMall); | |||||
| void updateStatus(WxCouponMall wxCouponMall); | void updateStatus(WxCouponMall wxCouponMall); | ||||
| void delteAllByProductId(WxCouponMall wxCouponMall); | void delteAllByProductId(WxCouponMall wxCouponMall); | ||||
| } | } | ||||
| @@ -125,4 +125,6 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> { | |||||
| List<TtCouponVo> ttCouponList(TtCouponVo ttCouponVo); | List<TtCouponVo> ttCouponList(TtCouponVo ttCouponVo); | ||||
| Integer findCategoryIdById(@Param("id")Long id,@Param("tenantId")String tenantId); | Integer findCategoryIdById(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| void setMakeMerchantId(WxCoupon couponQ); | |||||
| } | } | ||||
| @@ -23,8 +23,9 @@ public interface WxCouponMallService { | |||||
| PageInfo<WxCouponMall> listAsPage(WxCouponMall record, Integer pageIndex, Integer pageSize); | PageInfo<WxCouponMall> listAsPage(WxCouponMall record, Integer pageIndex, Integer pageSize); | ||||
| List<WxCouponMall> list(WxCouponMall wxCouponMall,boolean queryMall); | List<WxCouponMall> list(WxCouponMall wxCouponMall,boolean queryMall); | ||||
| List<Long> listCouponIds(WxCouponMall wxCouponMall); | |||||
| void finised(String tenantId,Long couponId,String mallTenantId); | |||||
| void unfinised(String tenantId, Long couponId,Integer couponType, String mallTenantId) throws Exception; | |||||
| void finised(String couponTenantId,Long couponId,String mallTenantId); | |||||
| void unfinised(String couponTenantId, Long couponId,Integer couponType, String mallTenantId) throws Exception; | |||||
| } | } | ||||
| @@ -81,7 +81,7 @@ public interface WxCouponService { | |||||
| WxCoupon getHtmlById(Long id,String tenantId); | WxCoupon getHtmlById(Long id,String tenantId); | ||||
| WxCouponCVo getVoById(Long id,String tenantId); | |||||
| WxCouponCVo getVoById(Long id,String couponTenantId,TenantEntity mallTenantEntity); | |||||
| WxCouponCVo getVoStatusById(Long id,String tenantId); | WxCouponCVo getVoStatusById(Long id,String tenantId); | ||||
| @@ -8,6 +8,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumAppPlat; | import com.iformall.enums.EnumAppPlat; | ||||
| import com.iformall.enums.EnumCouponChannelStatus; | import com.iformall.enums.EnumCouponChannelStatus; | ||||
| import com.iformall.enums.EnumCouponMallStatus; | import com.iformall.enums.EnumCouponMallStatus; | ||||
| import com.iformall.enums.EnumCouponMerchantStatus; | |||||
| import com.iformall.enums.EnumCouponType; | import com.iformall.enums.EnumCouponType; | ||||
| import com.iformall.enums.EnumSpuSyncStatus; | import com.iformall.enums.EnumSpuSyncStatus; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| @@ -31,6 +32,8 @@ public class WxCouponMallServiceImpl implements WxCouponMallService { | |||||
| WxCouponChannelMapper wxCouponChannelMapper; | WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @Autowired | @Autowired | ||||
| WxMallMapper wxMallMapper; | WxMallMapper wxMallMapper; | ||||
| @Autowired | |||||
| WxCouponMerchantMapper wxCouponMerchantMapper; | |||||
| @Override | @Override | ||||
| public List<WxCouponMall> list(WxCouponMall wxCouponMall,boolean queryMall){ | public List<WxCouponMall> list(WxCouponMall wxCouponMall,boolean queryMall){ | ||||
| @@ -61,15 +64,30 @@ public class WxCouponMallServiceImpl implements WxCouponMallService { | |||||
| return list; | return list; | ||||
| } | } | ||||
| @Override | |||||
| public List<Long> listCouponIds(WxCouponMall wxCouponMall){ | |||||
| return wxCouponMallMapper.findCouponIdList(wxCouponMall); | |||||
| } | |||||
| @Override | @Override | ||||
| public PageInfo<WxCouponMall> listAsPage(WxCouponMall record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCouponMall> listAsPage(WxCouponMall record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponMallMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponMallMapper.findList(record)); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void finised(String tenantId, Long couponId, String mallTenantId) { | |||||
| public void finised(String couponTenantId, Long couponId, String mallTenantId) { | |||||
| //查询商户设置了没有 | |||||
| WxCouponMerchant cmParam = new WxCouponMerchant(); | |||||
| cmParam.setTenantId(mallTenantId); | |||||
| cmParam.setProductId(couponId); | |||||
| cmParam.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | |||||
| List<WxCouponMerchant> merchantList = wxCouponMerchantMapper.findList(cmParam); | |||||
| if (null == merchantList || merchantList.size() <= 0 ) { | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"未设置有效商户"); | |||||
| } | |||||
| WxCouponMall couponMall = new WxCouponMall(); | WxCouponMall couponMall = new WxCouponMall(); | ||||
| couponMall.setTenantId(tenantId); | |||||
| couponMall.setTenantId(couponTenantId); | |||||
| couponMall.setMallTenantId(mallTenantId); | couponMall.setMallTenantId(mallTenantId); | ||||
| couponMall.setProductId(couponId); | couponMall.setProductId(couponId); | ||||
| couponMall.setStatus(EnumCouponMallStatus.FINISED.getCode()); | couponMall.setStatus(EnumCouponMallStatus.FINISED.getCode()); | ||||
| @@ -77,17 +95,17 @@ public class WxCouponMallServiceImpl implements WxCouponMallService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void unfinised(String tenantId, Long couponId,Integer couponType, String mallTenantId) throws Exception{ | |||||
| public void unfinised(String couponTenantId, Long couponId,Integer couponType, String mallTenantId) throws Exception{ | |||||
| //抖音平台查询的是未提交抖音审核的,微信是未上架的 | //抖音平台查询的是未提交抖音审核的,微信是未上架的 | ||||
| EnumAppPlat plat = EnumCouponType.getAppPlat(couponType); | EnumAppPlat plat = EnumCouponType.getAppPlat(couponType); | ||||
| if (plat == EnumAppPlat.TOUTIAO) { | if (plat == EnumAppPlat.TOUTIAO) { | ||||
| TtCouponChannelPoi poi = ttCouponChannelPoiMapper.selectById(tenantId, couponId); | |||||
| TtCouponChannelPoi poi = ttCouponChannelPoiMapper.selectById(couponTenantId, couponId); | |||||
| if (null != poi &&( EnumSpuSyncStatus.isValid(poi.getLastStatus()))) { | if (null != poi &&( EnumSpuSyncStatus.isValid(poi.getLastStatus()))) { | ||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"券已在抖音审核流程中,无法修改。"); | throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"券已在抖音审核流程中,无法修改。"); | ||||
| } | } | ||||
| }else if (plat == EnumAppPlat.WX) { | }else if (plat == EnumAppPlat.WX) { | ||||
| WxCouponChannel couponChannel = new WxCouponChannel(); | WxCouponChannel couponChannel = new WxCouponChannel(); | ||||
| couponChannel.setTenantId(tenantId); | |||||
| couponChannel.setTenantId(couponTenantId); | |||||
| couponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | couponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | ||||
| List<WxCouponChannel> clist = wxCouponChannelMapper.findList(couponChannel); | List<WxCouponChannel> clist = wxCouponChannelMapper.findList(couponChannel); | ||||
| if (null != clist && clist.size() > 0 ) { | if (null != clist && clist.size() > 0 ) { | ||||
| @@ -95,7 +113,7 @@ public class WxCouponMallServiceImpl implements WxCouponMallService { | |||||
| } | } | ||||
| } | } | ||||
| WxCouponMall couponMall = new WxCouponMall(); | WxCouponMall couponMall = new WxCouponMall(); | ||||
| couponMall.setTenantId(tenantId); | |||||
| couponMall.setTenantId(couponTenantId); | |||||
| couponMall.setMallTenantId(mallTenantId); | couponMall.setMallTenantId(mallTenantId); | ||||
| couponMall.setProductId(couponId); | couponMall.setProductId(couponId); | ||||
| couponMall.setStatus(EnumCouponMallStatus.UNFINISED.getCode()); | couponMall.setStatus(EnumCouponMallStatus.UNFINISED.getCode()); | ||||
| @@ -353,15 +353,15 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxCouponCVo getVoById(Long id,String tenantId) { | |||||
| WxCouponCVo wxCouponCVo = wxCouponMapper.findVoDetail(id,tenantId); | |||||
| public WxCouponCVo getVoById(Long id,String couponTenantId,TenantEntity mallTenantEntity) { | |||||
| WxCouponCVo wxCouponCVo = wxCouponMapper.findVoDetail(id,couponTenantId); | |||||
| if(wxCouponCVo == null){ | if(wxCouponCVo == null){ | ||||
| return null; | return null; | ||||
| } | } | ||||
| List<Long> couponIdList = new ArrayList<Long>(); | List<Long> couponIdList = new ArrayList<Long>(); | ||||
| couponIdList.add(wxCouponCVo.getId()); | couponIdList.add(wxCouponCVo.getId()); | ||||
| Map<Long, List<WxMerchantVo>> couponMerchantVoMap = wxMerchantService.findCouponMerchantVoList(couponIdList, wxCouponCVo,true); | |||||
| Map<Long, List<WxMerchantVo>> couponMerchantVoMap = wxMerchantService.findCouponMerchantVoList(couponIdList, mallTenantEntity,true); | |||||
| List<WxMerchantVo> merchantList = couponMerchantVoMap.get(wxCouponCVo.getId()); | List<WxMerchantVo> merchantList = couponMerchantVoMap.get(wxCouponCVo.getId()); | ||||
| if (merchantList != null) { | if (merchantList != null) { | ||||
| @@ -396,15 +396,20 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| private Long parseMerchantId(JSONObject merchantParam){ | private Long parseMerchantId(JSONObject merchantParam){ | ||||
| return Long.valueOf(merchantParam.getString("id")); | |||||
| if (!StringUtils.isBlank(merchantParam.getString("id"))){ | |||||
| return Long.valueOf(merchantParam.getString("id")); | |||||
| } | |||||
| return null; | |||||
| } | } | ||||
| private String parseParameter(JSONObject merchantParam){ | private String parseParameter(JSONObject merchantParam){ | ||||
| return merchantParam.getString("parameter"); | return merchantParam.getString("parameter"); | ||||
| } | } | ||||
| private Integer parseBusiness(JSONObject merchantParam){ | private Integer parseBusiness(JSONObject merchantParam){ | ||||
| String businessIdStr = merchantParam.getString("businessId"); | String businessIdStr = merchantParam.getString("businessId"); | ||||
| return Integer.valueOf(businessIdStr); | |||||
| if ( !StringUtils.isBlank(businessIdStr)) { | |||||
| return Integer.valueOf(businessIdStr); | |||||
| } | |||||
| return null; | |||||
| } | } | ||||
| private Integer parseSubBusiness(JSONObject merchantParam){ | private Integer parseSubBusiness(JSONObject merchantParam){ | ||||
| String subBusinessIdStr = merchantParam.getString("subBusinessId"); | String subBusinessIdStr = merchantParam.getString("subBusinessId"); | ||||
| @@ -768,8 +773,11 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| if (EnumPayMchType.DIRECT.equals(payMchType)) { | if (EnumPayMchType.DIRECT.equals(payMchType)) { | ||||
| WxMerchant makeMerchant = getDirectPayAccountMerchant(merchantList,record); | WxMerchant makeMerchant = getDirectPayAccountMerchant(merchantList,record); | ||||
| if (null == makeMerchant) { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "没有收款商户"); | |||||
| } | |||||
| record.setMakeMerchantId(makeMerchant.getId()); | record.setMakeMerchantId(makeMerchant.getId()); | ||||
| WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, makeMerchant.getId(), null, payMchType.getCode()); | |||||
| WxProfitSharingReceiver receiver = payShareServie.getReceiver(makeMerchant, makeMerchant.getId(), null, payMchType.getCode()); | |||||
| if (receiver == null) { | if (receiver == null) { | ||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]未配置收款账户"); | throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]未配置收款账户"); | ||||
| @@ -811,7 +819,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| WxMerchant makeMerchant = null; | WxMerchant makeMerchant = null; | ||||
| //平台券,集团商管商户 | //平台券,集团商管商户 | ||||
| if (EnumCouponType.COUPON_DOUYIN_PLAT.getCode() == coupon.getType()) { | if (EnumCouponType.COUPON_DOUYIN_PLAT.getCode() == coupon.getType()) { | ||||
| //TODO 查询集团商管商户 | |||||
| //查询集团商管商户 | |||||
| makeMerchant = wxMerchantService.findAdmin(coupon); | makeMerchant = wxMerchantService.findAdmin(coupon); | ||||
| //品牌券,查询集团品牌商户 | //品牌券,查询集团品牌商户 | ||||
| }else if (EnumCouponType.COUPON_DOUYIN_BRAND.getCode() == coupon.getType()) { | }else if (EnumCouponType.COUPON_DOUYIN_BRAND.getCode() == coupon.getType()) { | ||||
| @@ -1530,20 +1538,25 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| if (null == wxCoupon.getMerchantIds()) { | if (null == wxCoupon.getMerchantIds()) { | ||||
| throw new MallinkException(Result.ERROR,"请选择商户"); | throw new MallinkException(Result.ERROR,"请选择商户"); | ||||
| } | } | ||||
| Long makeMerchantId = coupon.getMakeMerchantId(); | |||||
| // | // | ||||
| StringBuffer merchantParams = new StringBuffer("{\"tenantId\":").append(mallTenantEntity.getTenantId()).append(",\"mallMerchantParams\":").append("["); | |||||
| StringBuffer merchantParams = new StringBuffer("[{\"tenantId\":").append(mallTenantEntity.getTenantId()).append(",\"mallMerchantParams\":").append("["); | |||||
| Long[] mids = wxCoupon.getMerchantIds(); | Long[] mids = wxCoupon.getMerchantIds(); | ||||
| for (int i = 0 ;i < mids.length; i++ ){ | for (int i = 0 ;i < mids.length; i++ ){ | ||||
| merchantParams.append("{\"id\":").append(mids[i]).append("}"); | |||||
| merchantParams.append("{\"id\":").append(mids[i]).append(",\"businessId\":").append(EnumBusiness.BUSINESS_ID6.getCode()).append("}"); | |||||
| if (i < mids.length-1 ) { | if (i < mids.length-1 ) { | ||||
| merchantParams.append(","); | merchantParams.append(","); | ||||
| } | } | ||||
| } | } | ||||
| merchantParams.append("]"); | |||||
| merchantParams.append("]}]"); | |||||
| coupon.setChildMerchantParams(merchantParams.toString()); | coupon.setChildMerchantParams(merchantParams.toString()); | ||||
| checkCouponMerchantReceiver(coupon,true); | checkCouponMerchantReceiver(coupon,true); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| updateCouponMerchants(coupon,idWorker); | updateCouponMerchants(coupon,idWorker); | ||||
| //平台券设置商管商户 | |||||
| if (null != coupon.getMakeMerchantId()) { | |||||
| wxCouponMapper.setMakeMerchantId(coupon); | |||||
| } | |||||
| }catch(Exception e) { | }catch(Exception e) { | ||||
| throw e; | throw e; | ||||
| } | } | ||||
| @@ -77,6 +77,11 @@ | |||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <select id="findCouponIdList" parameterType="com.iformall.domain.po.WxCouponMall" resultType="Long"> | |||||
| select product_id from wx_coupon_mall | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <update id = "updateStatus" parameterType="com.iformall.domain.po.WxCouponMall"> | <update id = "updateStatus" parameterType="com.iformall.domain.po.WxCouponMall"> | ||||
| update wx_coupon_mall set status = #{status} where `product_id` = #{productId} | update wx_coupon_mall set status = #{status} where `product_id` = #{productId} | ||||
| and `tenant_id` = #{tenantId} and `mall_tenant_id` = #{mallTenantId} | and `tenant_id` = #{tenantId} and `mall_tenant_id` = #{mallTenantId} | ||||
| @@ -1494,5 +1494,9 @@ | |||||
| where id = #{id} | where id = #{id} | ||||
| and tenant_id = #{tenantId} | and tenant_id = #{tenantId} | ||||
| </select> | </select> | ||||
| <update id="setMakeMerchantId" parameterType="com.iformall.domain.po.WxCoupon" > | |||||
| update wx_coupon set make_merchant_id = #{makeMerchantId} where id = #{id} and tenant_id = #{tenantId} | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||