| @@ -13,6 +13,9 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| @RestController | |||
| @RequestMapping("wxBusiness") | |||
| public class WxBusinessController extends BaseController { | |||
| @@ -33,6 +36,17 @@ public class WxBusinessController extends BaseController { | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("成长值业态列表接口") | |||
| @GetMapping("busListForScore") | |||
| public ResultData getList(@ModelAttribute WxBusiness wxBusiness) { | |||
| logger.debug("[" + getIpAddr() + "] WxBusinessController::getList"); | |||
| if (null == wxBusiness) wxBusiness = new WxBusiness(); | |||
| final List<WxBusiness> busList = wxBusinessService.getList(wxBusiness); | |||
| // 业态 全部 不返回 | |||
| List<WxBusiness> busList2 = busList.stream().filter(b -> !b.getId().equals(0L)).collect(Collectors.toList()); | |||
| return new ResultData(busList2); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxBusiness wxBusiness) { | |||
| @@ -28,7 +28,15 @@ public class WxScoreRules implements Serializable { | |||
| private static final String defaultRules = | |||
| "[" + | |||
| "{\"id\":1,\"limit\":0,\"step\":1,\"score\":10 ,\"desc\":\"每日登陆\"}," + | |||
| "{\"id\":2,\"limit\":0,\"step\":1,\"score\":50 ,\"desc\":\"线上交易1元\"}," + | |||
| // "{\"id\":2,\"limit\":0,\"step\":1,\"score\":50 ,\"desc\":\"线上交易1元\"}," + | |||
| "{\"id\":2,\"childs\":[" + | |||
| " {\"businessId\":1,\"limit\":0,\"step\":1,\"score\":50 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":2,\"limit\":0,\"step\":1,\"score\":50 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":3,\"limit\":0,\"step\":1,\"score\":50 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":4,\"limit\":0,\"step\":1,\"score\":50 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":5,\"limit\":0,\"step\":1,\"score\":50 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":6,\"limit\":0,\"step\":1,\"score\":50 ,\"desc\":\"线上交易1元\"}" + | |||
| "]}," + | |||
| "{\"id\":3,\"limit\":1,\"step\":1,\"score\":100,\"desc\":\"绑定车牌1个\"}," + | |||
| "{\"id\":4,\"limit\":0,\"step\":1,\"score\":10 ,\"desc\":\"连接WIFI1次\"}," + | |||
| "{\"id\":5,\"limit\":1,\"step\":1,\"score\":100,\"desc\":\"授权个人信息\"}," + | |||
| @@ -5,6 +5,7 @@ package com.iformall.enums; | |||
| */ | |||
| public enum EnumBusiness { | |||
| <<<<<<< HEAD | |||
| // 1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券 | |||
| BUSINESS_NULL(0, "无"), | |||
| BUSINESS_ID1(1, "餐饮"), | |||
| @@ -13,6 +14,16 @@ public enum EnumBusiness { | |||
| BUSINESS_ID4(4, "亲子"), | |||
| BUSINESS_ID5(5, "超市"), | |||
| BUSINESS_ID6(6, "其他"), | |||
| ======= | |||
| // 0:全部, 1:餐饮, 2:娱乐, 3:服饰, 4:亲子, 5:超市, 6:其他 | |||
| ALL(0, "全部"), | |||
| CATERING(1, "餐饮"), | |||
| ENTERTAINMENT(2, "娱乐"), | |||
| ATTIRE(3, "服饰"), | |||
| CHILD(4,"亲子"), | |||
| SUPERMARKET(5, "超市"), | |||
| OTHER(6, "其他") | |||
| >>>>>>> [成长值/消费][新增]:成长值/消费支持业态配置 | |||
| ; | |||
| public static EnumBusiness getEnum(Integer code) { | |||
| @@ -3,17 +3,27 @@ package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxBusiness; | |||
| import java.util.List; | |||
| public interface WxBusinessService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param offset | |||
| * @param limit | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<WxBusiness> listAsPage(WxBusiness record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据实体查询列表 | |||
| * | |||
| * @param record | |||
| * @return | |||
| */ | |||
| List<WxBusiness> getList(WxBusiness record); | |||
| /** | |||
| * 根据Id获得实体 | |||
| @@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.common.IdWorker; | |||
| import java.util.List; | |||
| @Service | |||
| public class WxBusinessServiceImpl implements WxBusinessService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -24,6 +26,11 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBusinessMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public List<WxBusiness> getList(WxBusiness record) { | |||
| return wxBusinessMapper.findList(record); | |||
| } | |||
| @Override | |||
| public WxBusiness getById(Integer id) { | |||
| return wxBusinessMapper.selectByPrimaryKey(id); | |||
| @@ -715,7 +715,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| // 成长值 计算 | |||
| try { | |||
| wxScoreRulesService.addScore2(EnumScoreType.CONSUMPTION, updateOrder, "6"); // bussinessId 6 其他 | |||
| wxScoreRulesService.addScore2(EnumScoreType.CONSUMPTION, updateOrder, EnumBusiness.OTHER.getCode()); | |||
| } catch (Exception e) { | |||
| logger.error("成长值:" + e.getMessage()); | |||
| } | |||
| @@ -1,8 +1,10 @@ | |||
| package com.iformall.service.impl; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.EnumBusiness; | |||
| import com.iformall.enums.EnumScoreType; | |||
| import com.iformall.mapper.WxScoreHistoryMapper; | |||
| import com.iformall.mapper.WxScoreRulesMapper; | |||
| @@ -10,6 +12,7 @@ import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxCUserService; | |||
| import com.iformall.service.WxScoreRulesService; | |||
| import com.iformall.utils.RedisUtils; | |||
| import jdk.nashorn.internal.ir.IdentNode; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -147,7 +150,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||
| return addScoreNumber; | |||
| } | |||
| private int payAddScore(WxOrder order, String bussinessId) { | |||
| private int payAddScore(WxOrder order, Integer businessId) { | |||
| int addScoreNumber = 0; | |||
| // 订单金额为0时不计入 | |||
| if (order.getPayment() == 0) | |||
| @@ -158,9 +161,23 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||
| // 2. 获取成长值 by id | |||
| JSONObject payRule = scoreRules.getRuleObj(EnumScoreType.CONSUMPTION); | |||
| // 3. 获取成长值 by 业态 | |||
| JSONObject busRule = payRule.getJSONObject(bussinessId); | |||
| if(busRule == null) { | |||
| busRule = payRule.getJSONObject("6"); // 其他 bussinessId 6 | |||
| JSONObject busRule = null; | |||
| JSONObject busRuleOther = null; | |||
| JSONArray busRules = payRule.getJSONArray("childs"); | |||
| if(busRules != null) { | |||
| for(int i=0;i<busRules.size();i++) { | |||
| JSONObject bus = (JSONObject)busRules.get(i); | |||
| Integer businessId1 = bus.getInteger("businessId"); | |||
| if (businessId.equals(businessId1)) { | |||
| busRule = bus; | |||
| } | |||
| if (businessId1.equals(EnumBusiness.OTHER.getCode())) { | |||
| busRuleOther = bus; | |||
| } | |||
| } | |||
| if(busRule == null) { | |||
| busRule = busRuleOther; | |||
| } | |||
| } | |||
| if (busRule == null) { | |||
| busRule = payRule; | |||
| @@ -316,7 +333,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||
| switch (scoreType){ | |||
| case CONSUMPTION: { | |||
| WxOrder order = (WxOrder) param1; | |||
| String bussinessId = param2.toString(); | |||
| Integer bussinessId = (Integer) param2; | |||
| return payAddScore(order, bussinessId); | |||
| } | |||
| default: { | |||