zq-erp/src/main/java/com/matrix/core/pojo/VerificationResult.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopOrderDaoV2.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopOrderV2Dao.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderDaoV2.xml | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderV2Dao.xml | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/test/java/com/matrix/JyyTests.java | ●●●●● patch | view | raw | blame | history |
zq-erp/src/main/java/com/matrix/core/pojo/VerificationResult.java
@@ -8,7 +8,7 @@ @Data public class VerificationResult { private boolean result; private boolean judgeResult; private String msg; @@ -18,24 +18,24 @@ } public static VerificationResult buildVerificationResult(boolean result){ public static VerificationResult buildVerificationResult(boolean judgeResult){ VerificationResult obj=new VerificationResult(); obj.result=result; obj.judgeResult =judgeResult; return obj ; } public static VerificationResult buildVerificationResult(boolean result,String msg){ public static VerificationResult buildVerificationResult(boolean judgeResult,String msg){ VerificationResult obj=new VerificationResult(); obj.result=result; obj.judgeResult =judgeResult; obj.msg=msg; return obj ; } public static VerificationResult buildVerificationResult(boolean result,Object info){ public static VerificationResult buildVerificationResult(boolean judgeResult,Object info){ VerificationResult obj=new VerificationResult(); obj.result=result; obj.judgeResult =judgeResult; obj.info=info; return obj ; } zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java
@@ -26,8 +26,7 @@ import com.matrix.system.fenxiao.entity.ShopSalesmanGrade; import com.matrix.system.fenxiao.vo.*; import com.matrix.system.hive.action.util.QueryUtil; import com.matrix.system.shopXcx.dao.ShopOrderDao; import com.matrix.system.shopXcx.dao.ShopOrderDaoV2; import com.matrix.system.shopXcx.dao.ShopOrderV2Dao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -61,7 +60,7 @@ BizUserService bizUserService; @Autowired ShopOrderDaoV2 shopOrderDaoV2; ShopOrderV2Dao shopOrderV2Dao; /** * 申请成为推广员 @@ -72,60 +71,65 @@ public ShopSalesmanApply applyToBeAnSalesman(String openId,String gradeId,String invitationId,int applyWay) { BizUser loginUser=bizUserDao.findByOpenId(openId); //校验审核状态,和是否重复发起 QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id",loginUser.getOpenId()); queryWrapper.in("apply_status",Arrays.asList("1,2".split(","))); ShopSalesmanApply checkApply = shopSalesmanApplyDao.selectOne(queryWrapper); if(checkApply==null|| checkApply.getApplyStatus()==ShopSalesmanApply.APPLY_STATUS_WTG){ //验证申请条件 VerificationResult verificationResult = isAbleToBeAnSalesman(openId); if(verificationResult.isJudgeResult()){ //校验审核状态,和是否重复发起 QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id",loginUser.getOpenId()); queryWrapper.in("apply_status",Arrays.asList("1,2".split(","))); ShopSalesmanApply checkApply = shopSalesmanApplyDao.selectOne(queryWrapper); if(checkApply==null|| checkApply.getApplyStatus()==ShopSalesmanApply.APPLY_STATUS_WTG){ ShopSalesmanApply shopSalesmanApply=new ShopSalesmanApply(); shopSalesmanApply.setUserId(openId); shopSalesmanApply.setCreateBy(MatrixConstance.SYSTEM_USER); shopSalesmanApply.setApplyWay(ShopSalesmanApply.APPLY_WAY_SELF); ShopSalesmanApply shopSalesmanApply=new ShopSalesmanApply(); shopSalesmanApply.setUserId(openId); shopSalesmanApply.setCompanyId(loginUser.getCompanyId()); shopSalesmanApply.setUpdateBy(MatrixConstance.SYSTEM_USER); Date date = new Date(); shopSalesmanApply.setCreateTime(date); shopSalesmanApply.setUpdateTime(date); shopSalesmanApply.setCreateBy(MatrixConstance.SYSTEM_USER); shopSalesmanApply.setApplyWay(ShopSalesmanApply.APPLY_WAY_SELF); if(StringUtils.isNotBlank(invitationId)){ shopSalesmanApply.setParentUserId(invitationId); }else if(StringUtils.isNotBlank(loginUser.getParentOpenId())){ //如果曾经是被邀请进来的则自动绑定为之前邀请人的下级 shopSalesmanApply.setParentUserId(loginUser.getParentOpenId()); } if(StringUtils.isNotBlank(gradeId)){ shopSalesmanApply.setGradeId(Long.parseLong(gradeId)); shopSalesmanApply.setCompanyId(loginUser.getCompanyId()); shopSalesmanApply.setUpdateBy(MatrixConstance.SYSTEM_USER); Date date = new Date(); shopSalesmanApply.setCreateTime(date); shopSalesmanApply.setUpdateTime(date); if(StringUtils.isNotBlank(invitationId)){ shopSalesmanApply.setParentUserId(invitationId); }else if(StringUtils.isNotBlank(loginUser.getParentOpenId())){ //如果曾经是被邀请进来的则自动绑定为之前邀请人的下级 shopSalesmanApply.setParentUserId(loginUser.getParentOpenId()); } if(StringUtils.isNotBlank(gradeId)){ shopSalesmanApply.setGradeId(Long.parseLong(gradeId)); }else{ //获取初始等级ID(公司id,是否为初始等级) Wrapper<ShopSalesmanGrade> queryWrapperOrepool = new QueryWrapper<>(); ((QueryWrapper<ShopSalesmanGrade>) queryWrapperOrepool).eq("company_id", loginUser.getCompanyId()); ((QueryWrapper<ShopSalesmanGrade>) queryWrapperOrepool).eq("is_default", 1); ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectOne(queryWrapperOrepool); shopSalesmanApply.setGradeId(shopSalesmanGrade.getId()); } shopSalesmanApply.setApplyWay(applyWay); BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_AUDIT_METHOD, loginUser.getCompanyId()); if(busParameterSettings!=null &&busParameterSettings.getParamValue().equals("1")){ //自动审核 shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_TG); bizUserService.setToBeAnSalesman(loginUser.getOpenId(),invitationId); }else{ shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_DSH); } shopSalesmanApplyDao.insert(shopSalesmanApply); return shopSalesmanApply; }else{ //获取初始等级ID(公司id,是否为初始等级) Wrapper<ShopSalesmanGrade> queryWrapperOrepool = new QueryWrapper<>(); ((QueryWrapper<ShopSalesmanGrade>) queryWrapperOrepool).eq("company_id", loginUser.getCompanyId()); ((QueryWrapper<ShopSalesmanGrade>) queryWrapperOrepool).eq("is_default", 1); ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectOne(queryWrapperOrepool); shopSalesmanApply.setGradeId(shopSalesmanGrade.getId()); throw new GlobleException("不能重复申请"); } shopSalesmanApply.setApplyWay(applyWay); BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_AUDIT_METHOD, loginUser.getCompanyId()); if(busParameterSettings!=null &&busParameterSettings.getParamValue().equals("1")){ //自动审核 shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_TG); bizUserService.setToBeAnSalesman(loginUser.getOpenId(),invitationId); }else{ shopSalesmanApply.setApplyStatus(ShopSalesmanApply.APPLY_STATUS_DSH); } shopSalesmanApplyDao.insert(shopSalesmanApply); return shopSalesmanApply; }else{ throw new GlobleException("不能重复申请"); throw new GlobleException(verificationResult.getMsg()); } } @@ -142,18 +146,29 @@ VerificationResult.buildVerificationResult(true); case FenxiaoSettingConstant.FX_APPLY_CONDITION_XFZDCP: VerificationResult.buildVerificationResult(true); int buyZdcpCount= shopOrderV2Dao.countBuyZdcp(openId,applyCondition.getParamValue1()); if(buyZdcpCount>0){ verificationResult= VerificationResult.buildVerificationResult(true); }else{ verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费指定产品后再申请!"); } case FenxiaoSettingConstant.FX_APPLY_CONDITION_XFRYCP: //判断用户是否有确认收货的产品 int receivedOrderCount= shopOrderDaoV2.selectReceivedOrderCount(openId); int receivedOrderCount= shopOrderV2Dao.selectReceivedOrderCount(openId); if(receivedOrderCount>0){ verificationResult= VerificationResult.buildVerificationResult(true); }else{ verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费任意产品后再申请!"); } case FenxiaoSettingConstant.FX_APPLY_CONDITION_XCZDJE: Double zdje=Double.parseDouble(applyCondition.getParamValue2()); Double yxfje=shopOrderV2Dao.countOrderAmount(openId); if(zdje>yxfje){ verificationResult=VerificationResult.buildVerificationResult(true); }else{ verificationResult= VerificationResult.buildVerificationResult(false,"不符合申请条件,请消费满"+zdje+"元后再申请!"); } VerificationResult.buildVerificationResult(true); default: VerificationResult.buildVerificationResult(true); zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
@@ -100,10 +100,17 @@ public AjaxResult applyToBeAnSalesman(@RequestBody Map<String,String> param) { BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); String invitationId = param.get("invitationId"); ShopSalesmanApply shopSalesmanApply= shopSalesmanApplyService.applyToBeAnSalesman(loginUser.getOpenId(),"",invitationId,ShopSalesmanApply.APPLY_WAY_SELF); loginUser=bizUserDao.selectById(loginUser.getUserId()); redisUserLoginUtils.updateUserInfo(loginUser); return AjaxResult.buildSuccessInstance(shopSalesmanApply); BizUser invitationUser = bizUserDao.findByOpenId(invitationId); if(invitationUser.getOpenId().equals(loginUser.getOpenId())){ return AjaxResult.buildFailInstance("不能邀请自己成为推广员"); }else{ ShopSalesmanApply shopSalesmanApply= shopSalesmanApplyService.applyToBeAnSalesman(loginUser.getOpenId(),"",invitationId,ShopSalesmanApply.APPLY_WAY_SELF); loginUser=bizUserDao.selectById(loginUser.getUserId()); redisUserLoginUtils.updateUserInfo(loginUser); return AjaxResult.buildSuccessInstance(shopSalesmanApply); } } @@ -116,6 +123,7 @@ BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id",loginUser.getOpenId()); queryWrapper.eq("apply_status",ShopSalesmanApply.APPLY_STATUS_DSH); ShopSalesmanApply shopSalesmanApply = salesmanApplyDao.selectOne(queryWrapper); return AjaxResult.buildSuccessInstance(shopSalesmanApply); } zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopOrderDaoV2.java
File was deleted zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopOrderV2Dao.java
New file @@ -0,0 +1,19 @@ package com.matrix.system.shopXcx.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.matrix.system.shopXcx.bean.ShopOrder; import org.apache.ibatis.annotations.Param; /** * @description 订单表 */ public interface ShopOrderV2Dao extends BaseMapper<ShopOrder> { /** 统计已收货订单数 */ int selectReceivedOrderCount(String openId); /** 统计已收货订单金额 */ Double countOrderAmount(String openId); /** 统计是否消费过了指定产品 */ int countBuyZdcp(@Param("openId") String openId, @Param("productIds")String productIds); } zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderDaoV2.xml
File was deleted zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderV2Dao.xml
New file @@ -0,0 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.matrix.system.shopXcx.dao.ShopOrderV2Dao"> <select id="selectReceivedOrderCount" resultType="java.lang.Integer"> select count(*) from shop_order where user_id = #{openId} and order_status in (4,5) </select> <select id="countOrderAmount" resultType="java.lang.Double"> select IFNULL(sum(IFNULL( order_money, 0 )),0) from shop_order where user_id = #{openId} and order_status in (4,5) </select> <select id="countBuyZdcp" resultType="java.lang.Integer"> select count(*) from shop_order a left join shop_order_details b on a.id=b.order_id where a.user_id=#{openId} and order_status in (4,5) and find_in_set(b.p_id,#{productIds}) </select> </mapper> zq-erp/src/test/java/com/matrix/JyyTests.java
New file @@ -0,0 +1,47 @@ package com.matrix; import com.matrix.system.shopXcx.dao.ShopOrderV2Dao; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; /** * 测试类示例 * * @author jiangyouyao * @email 512061637@qq.com * @date 2019年2月25日 */ @RunWith(SpringRunner.class) @SpringBootTest(classes = {ZqErpApplication.class},webEnvironment =SpringBootTest.WebEnvironment.RANDOM_PORT) public class JyyTests { @Autowired private ShopOrderV2Dao shopOrderV2Dao; /** * */ @Test public void testSelectReceivedOrderCount() throws InterruptedException { System.out.println( shopOrderV2Dao.selectReceivedOrderCount("oJkRK4yelehsY4S7I6Ee1ydWtQMI")); } @Test public void testCountOrderAmount() throws InterruptedException { System.out.println( shopOrderV2Dao.countOrderAmount("oJkRK4yelehsY4S7I6Ee1ydWtQMI")); } @Test public void countBuyZdcp() throws InterruptedException { System.out.println( shopOrderV2Dao.countBuyZdcp("oJkRK4yelehsY4S7I6Ee1ydWtQMI","1167,1263,1262")); } }