| @@ -74,9 +74,9 @@ public class WxCUserBasicInfoController extends BaseController { | |||
| private void setUserInfoLevel(WxCUserBasicInfo info) { | |||
| if (info.getPoins() == null || info.getPoins() == 0) { | |||
| info.setLevel("无"); | |||
| info.setLevel(WxLevelConfigService.DEFAULT_LEVEL); | |||
| } else { | |||
| info.setLevel("无"); | |||
| info.setLevel(WxLevelConfigService.DEFAULT_LEVEL); | |||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(info.getTenantId()); | |||
| for (WxLevelConfig levelConfig : levelList) { | |||
| if (info.getPoins() >= levelConfig.getPoints()) { | |||
| @@ -4,6 +4,8 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCUserVo; | |||
| import com.iformall.domain.vo.WxLevelMerchantCVo; | |||
| import com.iformall.enums.EnumLevelConfigDiscountStatus; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxCUserService; | |||
| import com.iformall.service.WxLevelConfigService; | |||
| @@ -71,42 +73,44 @@ public class WxMemController extends BaseController { | |||
| WxCUserVo userVo = new WxCUserVo(); | |||
| org.springframework.beans.BeanUtils.copyProperties(cUser, userVo); | |||
| if (userVo.getScore() == null || userVo.getScore() == 0) { | |||
| userVo.setLevelName("无"); | |||
| userVo.setDiscountRate(10000); // 无折扣 | |||
| } else { | |||
| userVo.setLevelName("无"); | |||
| Integer levelConfigDiscount = null; | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(cUser.getId()); | |||
| if (wxCUserBasicInfo != null) { | |||
| userVo.setName(wxCUserBasicInfo.getName()); | |||
| userVo.setBirthdate(wxCUserBasicInfo.getBirthdate()); | |||
| userVo.setSex(wxCUserBasicInfo.getSex()); | |||
| userVo.setAddress(wxCUserBasicInfo.getAddress()); | |||
| } | |||
| userVo.setLevelName(WxLevelConfigService.DEFAULT_LEVEL); | |||
| userVo.setDiscountRate(WxLevelConfigService.DEFAULT_MERCHANT_DISCOUNT); | |||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(bUser.getTenantId()); | |||
| if (userVo.getScore() != null) { | |||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(userVo.getTenantId()); | |||
| String level = WxLevelConfigService.DEFAULT_LEVEL; | |||
| Long levelId = 0L; | |||
| for(WxLevelConfig levelConfig: levelList) { | |||
| if (userVo.getScore() >= levelConfig.getPoints()) { | |||
| userVo.setLevelId(levelConfig.getId()); | |||
| userVo.setLevelName(levelConfig.getLevel()); | |||
| levelConfigDiscount = levelConfig.getDiscountEnable(); | |||
| if(levelConfig.getDiscountEnable().equals(EnumLevelConfigDiscountStatus.ENABLE.getCode())) | |||
| levelId = levelConfig.getId(); | |||
| level = levelConfig.getLevel(); | |||
| } | |||
| } | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(cUser.getId()); | |||
| if (wxCUserBasicInfo != null) { | |||
| userVo.setName(wxCUserBasicInfo.getName()); | |||
| userVo.setBirthdate(wxCUserBasicInfo.getBirthdate()); | |||
| userVo.setSex(wxCUserBasicInfo.getSex()); | |||
| userVo.setAddress(wxCUserBasicInfo.getAddress()); | |||
| } | |||
| if(levelConfigDiscount != null && levelConfigDiscount > 0) { | |||
| // 用户折扣率 | |||
| WxMerchant wxMerchant = wxMerchantService.getById(bUser.getMerchantId()); | |||
| if(wxMerchant != null) { | |||
| if(levelConfigDiscount.equals(1)) { // first level | |||
| userVo.setDiscountRate(wxMerchant.getVipDiscountRate1()); | |||
| } else if(levelConfigDiscount.equals(2)) { // second level | |||
| userVo.setDiscountRate(wxMerchant.getVipDiscountRate2()); | |||
| } else if(levelConfigDiscount.equals(3)) { // third level | |||
| userVo.setDiscountRate(wxMerchant.getVipDiscountRate3()); | |||
| } | |||
| } | |||
| userVo.setLevelId(levelId); | |||
| userVo.setLevelName(level); | |||
| WxLevelMerchant levelMerchant = new WxLevelMerchant(); | |||
| levelMerchant.setLevelId(levelId); | |||
| levelMerchant.setMerchantId(bUser.getMerchantId()); | |||
| List<WxLevelMerchantCVo> levelMerchantList = wxLevelConfigService.findListCVo(levelMerchant); | |||
| if (levelMerchantList.size() > 0) { | |||
| WxLevelMerchantCVo l = levelMerchantList.get(0); | |||
| userVo.setDiscountRate(l.getDiscount()); | |||
| } else { | |||
| userVo.setDiscountRate(WxLevelConfigService.DEFAULT_MERCHANT_DISCOUNT); | |||
| } | |||
| } | |||
| @@ -6,6 +6,8 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCUserVo; | |||
| import com.iformall.domain.vo.WxLevelMerchantCVo; | |||
| import com.iformall.enums.EnumLevelConfigDiscountStatus; | |||
| import com.iformall.enums.EnumMerchantBUserStatus; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.interceptor.AuthorizationInterceptor; | |||
| @@ -133,43 +135,32 @@ public class WxMerchantBUserController extends BaseController { | |||
| userVo.setScore(userInfo.getPoins()); | |||
| } | |||
| WxLevelConfig curLConfig = null; | |||
| int curDiscountRateIndex = 0; | |||
| int curDiscountRate = 0; | |||
| String level = WxLevelConfigService.DEFAULT_LEVEL; | |||
| Long levelId = 0L; | |||
| for(WxLevelConfig levelConfig: levelList) { | |||
| if (userVo.getScore() >= levelConfig.getPoints()) { | |||
| curLConfig = levelConfig; | |||
| } | |||
| } | |||
| if (curLConfig != null) { | |||
| userVo.setLevelId(curLConfig.getId()); | |||
| userVo.setLevelName(curLConfig.getLevel()); | |||
| curDiscountRateIndex = curLConfig.getDiscountEnable(); | |||
| if(curLConfig.getDiscountEnable() == 0) { // 未启用等级折扣 | |||
| userVo.setDiscountRate(0); // 折扣率为0 | |||
| userVo.setAmount(amount); | |||
| } else { | |||
| // 当前商户折扣率 | |||
| WxMerchant merchant = wxMerchantService.getById(bUser.getMerchantId()); | |||
| if (merchant == null){ | |||
| return new ResultData(ErrorCode.MCH_INFO_NOT_FOUND); | |||
| } | |||
| if(curDiscountRateIndex == 1) { | |||
| curDiscountRate = merchant.getVipDiscountRate1(); | |||
| } else if(curDiscountRateIndex == 2) { | |||
| curDiscountRate = merchant.getVipDiscountRate2(); | |||
| } else if(curDiscountRateIndex == 3) { | |||
| curDiscountRate = merchant.getVipDiscountRate3(); | |||
| } | |||
| userVo.setDiscountRate(curDiscountRate); | |||
| userVo.setAmount(amount*curDiscountRate/10000); | |||
| if (user.getScore() >= levelConfig.getPoints()) { | |||
| if(levelConfig.getDiscountEnable().equals(EnumLevelConfigDiscountStatus.ENABLE.getCode())) | |||
| levelId = levelConfig.getId(); | |||
| level = levelConfig.getLevel(); | |||
| } | |||
| } | |||
| userVo.setLevelId(levelId); | |||
| userVo.setLevelName(level); | |||
| WxLevelMerchant levelMerchant = new WxLevelMerchant(); | |||
| levelMerchant.setLevelId(levelId); | |||
| levelMerchant.setMerchantId(bUser.getMerchantId()); | |||
| List<WxLevelMerchantCVo> levelMerchantList = wxLevelConfigService.findListCVo(levelMerchant); | |||
| if (levelMerchantList.size() > 0) { | |||
| WxLevelMerchantCVo l = levelMerchantList.get(0); | |||
| userVo.setDiscountRate(l.getDiscount()); | |||
| userVo.setAmount(amount*l.getDiscount()/WxLevelConfigService.DEFAULT_MERCHANT_DISCOUNT); | |||
| } else { | |||
| userVo.setDiscountRate(WxLevelConfigService.DEFAULT_MERCHANT_DISCOUNT); // 折扣率为0 | |||
| userVo.setAmount(amount); | |||
| } | |||
| return new ResultData(userVo); | |||
| } | |||
| @@ -44,10 +44,6 @@ public class WxMallController extends BaseController { | |||
| @Autowired | |||
| private WxLevelConfigService wxLevelConfigService; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @AuthIgnore | |||
| @ApiOperation("商场图标") | |||
| @GetMapping("/getAppIcon") | |||
| @@ -116,16 +112,6 @@ public class WxMallController extends BaseController { | |||
| return new ResultData(Result.SUCCESS, "查询成功", map); | |||
| } | |||
| @ApiOperation("获取打折商户列表") | |||
| @GetMapping("/discountMerchantList") | |||
| public ResultData getMerchantId() { | |||
| WxCUser user = getUser(); | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.setTenantId(user.getTenantId()); | |||
| merchantQ.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| List<WxMerchantVo> list = wxMerchantService.getDisCountList(merchantQ); | |||
| return new ResultData(Result.SUCCESS, "查询成功", list); | |||
| } | |||
| @AuthIgnore | |||
| @ApiOperation("获取后端版本号") | |||
| @@ -15,6 +15,7 @@ import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCUserVo; | |||
| import com.iformall.domain.vo.WxLevelMerchantCVo; | |||
| import com.iformall.enums.EnumAssignTagsTrigger; | |||
| import com.iformall.enums.EnumLevelConfigDiscountStatus; | |||
| import com.iformall.enums.EnumScoreType; | |||
| import com.iformall.interceptor.AuthorizationInterceptor; | |||
| import com.iformall.service.*; | |||
| @@ -411,9 +412,9 @@ public class WxUserGrantController extends BaseController { | |||
| WxCUserVo userVo = new WxCUserVo(); | |||
| org.springframework.beans.BeanUtils.copyProperties(user, userVo); | |||
| if (userVo.getScore() == null || userVo.getScore() == 0) { | |||
| userVo.setLevelName("无"); | |||
| userVo.setLevelName(WxLevelConfigService.DEFAULT_LEVEL); | |||
| } else { | |||
| userVo.setLevelName("无"); | |||
| userVo.setLevelName(WxLevelConfigService.DEFAULT_LEVEL); | |||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(user.getTenantId()); | |||
| for(WxLevelConfig levelConfig: levelList) { | |||
| if (userVo.getScore() >= levelConfig.getPoints()) { | |||
| @@ -575,11 +576,12 @@ public class WxUserGrantController extends BaseController { | |||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(user.getTenantId()); | |||
| String level = "无"; | |||
| String level = WxLevelConfigService.DEFAULT_LEVEL; | |||
| Long levelId = 0L; | |||
| for(WxLevelConfig levelConfig: levelList) { | |||
| if (user.getScore() >= levelConfig.getPoints()) { | |||
| levelId = levelConfig.getId(); | |||
| if(levelConfig.getDiscountEnable().equals(EnumLevelConfigDiscountStatus.ENABLE.getCode())) | |||
| levelId = levelConfig.getId(); | |||
| level = levelConfig.getLevel(); | |||
| } | |||
| } | |||
| @@ -137,15 +137,6 @@ public class WxMerchant implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="品牌",name="brand") | |||
| private Long brand; | |||
| @io.swagger.annotations.ApiModelProperty(value="VIP折扣率1",name="vipDiscountRate1") | |||
| private Integer vipDiscountRate1; | |||
| @io.swagger.annotations.ApiModelProperty(value="VIP折扣率2",name="vipDiscountRate2") | |||
| private Integer vipDiscountRate2; | |||
| @io.swagger.annotations.ApiModelProperty(value="VIP折扣率3",name="vipDiscountRate3") | |||
| private Integer vipDiscountRate3; | |||
| @io.swagger.annotations.ApiModelProperty(value = "类型", name = "type") | |||
| private Integer type; | |||
| @@ -369,29 +360,6 @@ public class WxMerchant implements Serializable { | |||
| this.wxMerchantTax = wxMerchantTax; | |||
| } | |||
| public Integer getVipDiscountRate1() { | |||
| return vipDiscountRate1; | |||
| } | |||
| public void setVipDiscountRate1(Integer vipDiscountRate1) { | |||
| this.vipDiscountRate1 = vipDiscountRate1; | |||
| } | |||
| public Integer getVipDiscountRate2() { | |||
| return vipDiscountRate2; | |||
| } | |||
| public void setVipDiscountRate2(Integer vipDiscountRate2) { | |||
| this.vipDiscountRate2 = vipDiscountRate2; | |||
| } | |||
| public Integer getVipDiscountRate3() { | |||
| return vipDiscountRate3; | |||
| } | |||
| public void setVipDiscountRate3(Integer vipDiscountRate3) { | |||
| this.vipDiscountRate3 = vipDiscountRate3; | |||
| } | |||
| public String getAccountParameter() { | |||
| return accountParameter; | |||
| @@ -52,15 +52,6 @@ public class WxMerchantVo { | |||
| @io.swagger.annotations.ApiModelProperty(value="楼层",name="floorName") | |||
| private String floorName; | |||
| @io.swagger.annotations.ApiModelProperty(value="VIP折扣率1",name="vipDiscountRate1") | |||
| private Integer vipDiscountRate1; | |||
| @io.swagger.annotations.ApiModelProperty(value="VIP折扣率2",name="vipDiscountRate2") | |||
| private Integer vipDiscountRate2; | |||
| @io.swagger.annotations.ApiModelProperty(value="VIP折扣率3",name="vipDiscountRate3") | |||
| private Integer vipDiscountRate3; | |||
| public String getBuildingName() {return buildingName; } | |||
| public void setBuildingName(String _building) { | |||
| @@ -134,29 +125,4 @@ public class WxMerchantVo { | |||
| } | |||
| public Integer getVipDiscountRate1() { | |||
| return vipDiscountRate1; | |||
| } | |||
| public void setVipDiscountRate1(Integer vipDiscountRate1) { | |||
| this.vipDiscountRate1 = vipDiscountRate1; | |||
| } | |||
| public Integer getVipDiscountRate2() { | |||
| return vipDiscountRate2; | |||
| } | |||
| public void setVipDiscountRate2(Integer vipDiscountRate2) { | |||
| this.vipDiscountRate2 = vipDiscountRate2; | |||
| } | |||
| public Integer getVipDiscountRate3() { | |||
| return vipDiscountRate3; | |||
| } | |||
| public void setVipDiscountRate3(Integer vipDiscountRate3) { | |||
| this.vipDiscountRate3 = vipDiscountRate3; | |||
| } | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumLevelConfigDiscountStatus { | |||
| DISABLE(0, "停用"), | |||
| ENABLE(1, "启用"), | |||
| ; | |||
| public static EnumLevelConfigDiscountStatus getEnum(Integer code) { | |||
| for (EnumLevelConfigDiscountStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumLevelConfigDiscountStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -9,13 +9,6 @@ public interface WxMerchantMapper extends CommonMapper<WxMerchant, Long> { | |||
| List<WxMerchant> findList(WxMerchant wxMerchant); | |||
| List<WxMerchantVo> findDiscountList(WxMerchant wxMerchant); | |||
| WxMerchantVo getMerchantByCode(HashMap<String, String> params); | |||
| } | |||
| @@ -10,7 +10,9 @@ import java.util.List; | |||
| public interface WxLevelConfigService { | |||
| public final static String CAPABILITY_SEND_CAR_COUPON = "carCouponCount"; | |||
| public final static int DEFAULT_MERCHANT_DISCOUNT = 100; | |||
| public final static String DEFAULT_LEVEL = "无"; | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| @@ -24,14 +24,6 @@ public interface WxMerchantService { | |||
| */ | |||
| PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @return | |||
| */ | |||
| List<WxMerchantVo> getDisCountList(WxMerchant record); | |||
| /** | |||
| * 根据code查询 | |||
| * | |||
| @@ -21,7 +21,7 @@ import java.util.List; | |||
| @Service | |||
| public class WxLevelConfigServiceImpl implements WxLevelConfigService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private final static String CAPABILITY_SEND_CAR_COUPON = "carCouponCount"; | |||
| @Autowired | |||
| WxLevelConfigMapper wxLevelConfigMapper; | |||
| @@ -42,7 +42,6 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService { | |||
| return page; | |||
| } | |||
| public final static int DEFAULT_MERCHANT_DISCOUNT = 100; | |||
| @Override | |||
| public List<WxLevelConfig> listByMerchantId(Long merchantId, WxLevelConfig record) { | |||
| @@ -120,14 +119,15 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService { | |||
| if(levelConfig.getId() == null) { | |||
| levelConfig.setId(idWorker.nextId()); | |||
| levelConfig.setCreateDate(new Date()); | |||
| levelConfig.setUpdateDate(new Date()); | |||
| } else { | |||
| levelConfig.setUpdateDate(new Date()); | |||
| } | |||
| levelConfig.setTenantId(tenantId); | |||
| wxLevelConfigMapper.insertSelective(levelConfig); | |||
| } | |||
| } | |||
| public final static String CAPABILITY_SEND_CAR_COUPON = "carCouponCount"; | |||
| @Override | |||
| public void batchUpdateCapabilities(String tenantId, List<WxLevelConfig> records) { | |||
| records.stream() | |||
| @@ -103,11 +103,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| return pageInfo; | |||
| } | |||
| @Override | |||
| public List<WxMerchantVo> getDisCountList(WxMerchant record) { | |||
| return wxMerchantMapper.findDiscountList(record); | |||
| } | |||
| @Override | |||
| public WxMerchantVo getMerchantInfo(HashMap<String, String> params) { | |||
| return wxMerchantMapper.getMerchantByCode(params); | |||
| @@ -16,16 +16,13 @@ | |||
| <result column="business_id" jdbcType="INTEGER" property="businessId"/> | |||
| <result column="shop_type" jdbcType="INTEGER" property="shopType"/> | |||
| <result column="brand" jdbcType="VARCHAR" property="brand"/> | |||
| <result column="vip_discount_rate1" jdbcType="SMALLINT" property="vipDiscountRate1"/> | |||
| <result column="vip_discount_rate2" jdbcType="SMALLINT" property="vipDiscountRate2"/> | |||
| <result column="vip_discount_rate3" jdbcType="SMALLINT" property="vipDiscountRate3"/> | |||
| <result column="type" jdbcType="SMALLINT" property="type"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status`,`link_person`, | |||
| `business_id`,`shop_type`,`brand`,`vip_discount_rate1`,`vip_discount_rate2`,`vip_discount_rate3`,`type` | |||
| `business_id`,`shop_type`,`brand`,`type` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -99,8 +96,7 @@ | |||
| m.id, | |||
| m.img_url,m.name,m.link_phone,m.status, | |||
| s.addr,s.shop_number,s.baidu_poi, | |||
| mb.building_name,mf.floor_name, | |||
| m.vip_discount_rate1, m.vip_discount_rate2, m.vip_discount_rate3 | |||
| mb.building_name,mf.floor_name | |||
| </sql> | |||
| <resultMap id="MerchantDiscountVoResultMap" type="com.iformall.domain.vo.WxMerchantVo"> | |||
| @@ -116,29 +112,8 @@ | |||
| <result column="floor_name" jdbcType="VARCHAR" property="floorName"/> | |||
| <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/> | |||
| <result column="vip_discount_rate1" jdbcType="SMALLINT" property="vipDiscountRate1"/> | |||
| <result column="vip_discount_rate2" jdbcType="SMALLINT" property="vipDiscountRate2"/> | |||
| <result column="vip_discount_rate3" jdbcType="SMALLINT" property="vipDiscountRate3"/> | |||
| </resultMap> | |||
| <select id="findDiscountList" parameterType="java.util.Map" resultMap="MerchantDiscountVoResultMap"> | |||
| select | |||
| <include refid="allMerchantDiscountVoColumns"/> | |||
| FROM wx_merchant m | |||
| left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0 | |||
| left join wx_shop s on ms.shop_id = s.id | |||
| left join wx_mall_building mb on s.building = mb.id | |||
| left join wx_mall_floor mf on s.floor = mf.id | |||
| <where> | |||
| <if test=" null != tenantId "> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != status "> | |||
| and m.`status` = #{status} | |||
| </if> | |||
| and ( m.`vip_discount_rate1` > 0 or m.`vip_discount_rate2` > 0 or m.`vip_discount_rate3` > 0) | |||
| </where> | |||
| </select> | |||
| <select id="getMerchantByCode" parameterType="java.util.Map" resultMap="MerchantDiscountVoResultMap"> | |||
| select | |||