Browse Source

wx_coupon_send添加分表

release_toaliyun_real
xiaohanzi 5 years ago
parent
commit
970d7a860f
7 changed files with 37 additions and 18 deletions
  1. +2
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java
  2. +7
    -0
      mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java
  3. +6
    -2
      mallinkService/src/main/java/com/iformall/mapper/WxCouponSendMapper.java
  4. +4
    -4
      mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java
  5. +8
    -8
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java
  6. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  7. +9
    -1
      mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml

+ 2
- 2
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java View File

@@ -150,7 +150,7 @@ public class WxCouponSendController extends BaseController {
@SystemControllerLog(description = "注券-删除")
public ResultData delete(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponSendController::delete");
WxCouponSend wxCouponSend = wxCouponSendService.getById(id);
WxCouponSend wxCouponSend = wxCouponSendService.getById(id,getTenantInfo().getTenantId());
if (wxCouponSend == null) {
return new ResultData(ErrorCode.COUPON_SEND_IS_INVALID);
}
@@ -168,7 +168,7 @@ public class WxCouponSendController extends BaseController {
@SystemControllerLog(description = "注券-查询")
public ResultData findById(Long id) {
logger.debug("[" + getIpAddr() + "] WxCouponSendController::findById");
return new ResultData(Result.SUCCESS, "查询成功", wxCouponSendService.getById(id));
return new ResultData(Result.SUCCESS, "查询成功", wxCouponSendService.getById(id,getTenantInfo().getTenantId()));
}




+ 7
- 0
mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java View File

@@ -98,6 +98,13 @@ public class BaseMyBatisConfiguration {
wxCouponOrderSharding.setRule(EnumShardingRule.HASH.getCode());
shardingList.add(wxCouponOrderSharding);
ShardingSphere wxCouponSendSharding = new ShardingSphere();
wxCouponSendSharding.setColumn("tenant_id");
wxCouponSendSharding.setTableName("wx_coupon_send");
wxCouponSendSharding.setCount(100);
wxCouponSendSharding.setRule(EnumShardingRule.HASH.getCode());
shardingList.add(wxCouponSendSharding);
ShardingSphere wxOrderGroupSharding = new ShardingSphere();
wxOrderGroupSharding.setColumn("tenant_id");
wxOrderGroupSharding.setTableName("wx_order_group");


+ 6
- 2
mallinkService/src/main/java/com/iformall/mapper/WxCouponSendMapper.java View File

@@ -8,6 +8,10 @@ import org.apache.ibatis.annotations.Param;

public interface WxCouponSendMapper extends CommonMapper<WxCouponSend, String> {

WxCouponSend selectById(@Param("id")Long id,@Param("tenantId")String tenantId);
int deleteById(@Param("id")Long id,@Param("tenantId")String tenantId);
List<WxCouponSendVo> findListVo(WxCouponSend wxCouponSend);
List<WxCouponSendVo> findListVoByValidType(WxCouponSend wxCouponSend);

@@ -25,7 +29,7 @@ public interface WxCouponSendMapper extends CommonMapper<WxCouponSend, String> {
* @param merchantSend 当前已发数
* @param number 减少数量
*/
Integer reduceMerchantSend(Long id, Integer merchantRemain,Integer merchantSend,Integer number);
Integer reduceMerchantSend(@Param("tenantId")String tenantId,@Param("id")Long id, @Param("merchantRemain")Integer merchantRemain,@Param("merchantSend")Integer merchantSend,@Param("number")Integer number);

/**
* 商户注券 库存退回
@@ -35,6 +39,6 @@ public interface WxCouponSendMapper extends CommonMapper<WxCouponSend, String> {
* @param merchantSend 当前已发数
* @param number 回退数量
*/
Integer backMerchantSend(Long id, Integer merchantRemain, Integer merchantSend,Integer number);
Integer backMerchantSend(@Param("tenantId")String tenantId,@Param("id")Long id, @Param("merchantRemain")Integer merchantRemain,@Param("merchantSend")Integer merchantSend,@Param("number")Integer number);

}

+ 4
- 4
mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java View File

@@ -25,7 +25,7 @@ public interface WxCouponSendService {
* @param id
* @return
*/
WxCouponSend getById(Long id);
WxCouponSend getById(Long id,String tenantId);
/**
* 保存或更新实体
@@ -45,7 +45,7 @@ public interface WxCouponSendService {
*
* @param id
*/
void deleteById(Long id);
void deleteById(Long id,String tenantId);

/**
*停车或核销给用户注入卡券
@@ -80,7 +80,7 @@ public interface WxCouponSendService {
* @param merchantSend 当前已发
* @param number 减少数量
*/
void reduceMerchantSend(Long id, Integer merchantRemain, Integer merchantSend ,Integer number);
void reduceMerchantSend(String tenantId,Long id, Integer merchantRemain, Integer merchantSend ,Integer number);

/**
* 商户注券 库存退回
@@ -90,7 +90,7 @@ public interface WxCouponSendService {
* @param merchantSend 当前已发
* @param number 回退数量
*/
void backMerchantRemainInventory(Long id, Integer merchantRemain, Integer merchantSend ,Integer number);
void backMerchantRemainInventory(String tenantId,Long id, Integer merchantRemain, Integer merchantSend ,Integer number);

/**
*


+ 8
- 8
mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java View File

@@ -109,8 +109,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
}

@Override
public WxCouponSend getById(Long id) {
return wxCouponSendMapper.selectById(id);
public WxCouponSend getById(Long id,String tenantId) {
return wxCouponSendMapper.selectById(id,tenantId);
}

@Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class})
@@ -217,8 +217,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
}

@Override
public void deleteById(Long id) {
wxCouponSendMapper.deleteById(id);
public void deleteById(Long id,String tenantId) {
wxCouponSendMapper.deleteById(id,tenantId);
}

private boolean isConditionAllowed(WxCouponSend wxCouponSend, Object param) {
@@ -609,16 +609,16 @@ public class WxCouponSendServiceImpl implements WxCouponSendService {
}

@Override
public void reduceMerchantSend(Long id, Integer merchantRemain, Integer merchantSend ,Integer number) {
int num = wxCouponSendMapper.reduceMerchantSend(id, merchantRemain, merchantSend,number);
public void reduceMerchantSend(String tenantId,Long id, Integer merchantRemain, Integer merchantSend ,Integer number) {
int num = wxCouponSendMapper.reduceMerchantSend(tenantId,id, merchantRemain, merchantSend,number);
if (num == 0) {
throw new MallinkException(ErrorCode.ORDER_IS_FAIL);
}
}

@Override
public void backMerchantRemainInventory(Long id, Integer merchantRemain, Integer merchantSend, Integer number) {
int num = wxCouponSendMapper.backMerchantSend(id, merchantRemain, merchantSend,number);
public void backMerchantRemainInventory(String tenantId,Long id, Integer merchantRemain, Integer merchantSend, Integer number) {
int num = wxCouponSendMapper.backMerchantSend(tenantId,id, merchantRemain, merchantSend,number);
if (num == 0) {
throw new MallinkException(ErrorCode.ORDER_IS_FAIL);
}


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java View File

@@ -568,7 +568,7 @@ public class WxOrderServiceImpl implements WxOrderService {

try {
// 减库存
wxCouponSendService.reduceMerchantSend(wxCouponSendVo.getId(), merchantRemain, merchantSend, 1);
wxCouponSendService.reduceMerchantSend(coupon.getTenantId(),wxCouponSendVo.getId(), merchantRemain, merchantSend, 1);
} catch (RuntimeException e) {
logger.error("此券减库存失败, couponId: {}, error: {}", couponIdStr, e.getMessage());
throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), coupon.getTitle() + ErrorCode.ORDER_IS_LIMITED.getMessage());


+ 9
- 1
mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml View File

@@ -99,6 +99,14 @@
</if>
</sql>

<select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_coupon_send cs where cs.id = #{id} and cs.tenant_id = #{tenantId}
</select>
<delete id="deleteById" parameterType="java.util.HashMap">
delete from wx_coupon_send cs where cs.id = #{id} and cs.tenant_id = #{tenantId}
</delete>

<select id="findListVo" parameterType="com.iformall.domain.vo.WxCouponSendVo" resultMap="BaseResultMap">
select <include refid="allColumns" />
from wx_coupon_send cs
@@ -166,7 +174,7 @@
where c.id = cs.coupon_id and cs.status = 0 and
((c.status = 1) or (c.valid_type = 1 and c.valid_end_date &lt; now()))
</update>
<update id="reduceMerchantSend">
<update id="reduceMerchantSend" parameterType="java.util.HashMap">
update wx_coupon_send
SET conditions = JSON_SET(conditions, '$.merchantRemain', #{merchantRemain} - #{number} , '$.merchantSend',
#{merchantSend} + #{number})


Loading…
Cancel
Save