|
|
|
@@ -5,7 +5,11 @@ import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.simple.domain.dto.WxCUserBasicInfoDto; |
|
|
|
import com.simple.domain.po.WxCUser; |
|
|
|
import com.simple.domain.po.WxCouponOrder; |
|
|
|
import com.simple.domain.po.WxScoreRules; |
|
|
|
import com.simple.mapper.WxCUserMapper; |
|
|
|
import com.simple.mapper.WxCouponOrderMapper; |
|
|
|
import com.simple.mapper.WxScoreRulesMapper; |
|
|
|
import com.simple.service.WxCUserService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@@ -17,6 +21,12 @@ public class WxCUserServiceImpl implements WxCUserService { |
|
|
|
@Autowired |
|
|
|
WxCUserMapper wxCUserMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCouponOrderMapper wxCouponOrderMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxScoreRulesMapper wxScoreRulesMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxCUser> listAsPage(WxCUser record, Integer pageIndex, Integer pageSize) { |
|
|
|
@@ -75,7 +85,36 @@ public class WxCUserServiceImpl implements WxCUserService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void scoreCalculate(String tenantId, Long cUserId) { |
|
|
|
// login count |
|
|
|
int login_count = 0; |
|
|
|
WxCUser user = wxCUserMapper.selectByPrimaryKey(cUserId); |
|
|
|
if (user != null) { |
|
|
|
login_count = user.getLoginCount(); |
|
|
|
} |
|
|
|
// coupon order |
|
|
|
WxCouponOrder couponOrder = new WxCouponOrder(); |
|
|
|
couponOrder.setTenantId(tenantId); |
|
|
|
couponOrder.setCUserId(cUserId); |
|
|
|
int counponCount = wxCouponOrderMapper.selectCount(couponOrder); |
|
|
|
|
|
|
|
// score rule |
|
|
|
WxScoreRules scoreRuleQ = new WxScoreRules(); |
|
|
|
scoreRuleQ.setTenantId(tenantId); |
|
|
|
WxScoreRules scoreRules = wxScoreRulesMapper.selectOne(scoreRuleQ); |
|
|
|
if (scoreRules != null) { |
|
|
|
Integer score = |
|
|
|
(login_count / scoreRules.getLoginCount()) * scoreRules.getLoginScoreNumber() |
|
|
|
+ (counponCount / scoreRules.getConsumptionScoreNumber()) * scoreRules.getConsumptionAmount(); |
|
|
|
if (user != null) { |
|
|
|
user.setScore(score); |
|
|
|
user.setUpdateDate(new Date()); |
|
|
|
wxCUserMapper.updateByPrimaryKeySelective(user); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|