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