售中提成计算,售前推送提成计算,优化修改客户手机号时更改绑定对应的微信用户逻辑

This commit is contained in:
xiezhijun 2021-06-02 18:19:01 +08:00
parent 7cb4122891
commit 0d7f9478fa
12 changed files with 144 additions and 16 deletions

View File

@ -8,6 +8,7 @@ import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.custom.domain.SysCommissionDayDetail; import com.stdiet.custom.domain.SysCommissionDayDetail;
import com.stdiet.custom.domain.SysOrder; import com.stdiet.custom.domain.SysOrder;
import com.stdiet.custom.domain.SysOrderCommisionDayDetail; import com.stdiet.custom.domain.SysOrderCommisionDayDetail;
@ -169,12 +170,45 @@ public class SysCommisionController extends BaseController {
public TableDataInfo getDetail(SysCommision sysCommision) { public TableDataInfo getDetail(SysCommision sysCommision) {
startPage(); startPage();
if(sysCommision.getPostId() != null && sysCommision.getPostId().intValue() > 0){ if(sysCommision.getPostId() != null && sysCommision.getPostId().intValue() > 0){
//查询售后所有ID String postCodeId = "";
SysCommision param = new SysCommision(); switch (sysCommision.getPostId().intValue()){
param.setPostId(sysCommision.getPostId()); case 5:
List<Long> userIds = sysCommisionService.getAfterSaleId(param); postCodeId = "pre_sale_id";
sysCommision.setUserIds(userIds.size() == 0 ? null : userIds); break;
case 18:
postCodeId = "push_pre_sale_id";
break;
case 16:
postCodeId = "on_sale_id";
break;
case 6:
postCodeId = "after_sale_id";
break;
case 9:
postCodeId = "nutritionist_id";
break;
case 10:
postCodeId = "nutri_assis_id";
break;
case 11:
postCodeId = "operator_id";
break;
case 13:
postCodeId = "operator_assis_id";
break;
case 7:
postCodeId = "planner_id";
break;
case 8:
postCodeId = "planner_assis_id";
break;
default:
}
if(StringUtils.isEmpty(postCodeId)){
sysCommision.setPostId(null); sysCommision.setPostId(null);
}else{
sysCommision.setPostCode(postCodeId);
}
} }
List<SysCommision> list = sysCommisionService.selectSysCommisionDetail(sysCommision); List<SysCommision> list = sysCommisionService.selectSysCommisionDetail(sysCommision);
for (SysCommision detail : list) { for (SysCommision detail : list) {

View File

@ -38,6 +38,11 @@ public class SysCommision extends BaseEntity {
*/ */
private Long postId; private Long postId;
/**
* 岗位编码code
*/
private String postCode;
/** /**
* 业务员 * 业务员
*/ */

View File

@ -70,4 +70,11 @@ public interface SysWxUserInfoMapper
* @return * @return
*/ */
public SysWxUserInfo getSysWxUserInfoByPhone(@Param("phone")String phone); public SysWxUserInfo getSysWxUserInfoByPhone(@Param("phone")String phone);
/**
* 根据openid移除对应绑定的cusId
* @param openid
* @return
*/
public int removeCusIdByOpenId(@Param("openid")String openid);
} }

View File

@ -70,5 +70,12 @@ public interface ISysWxUserInfoService
*/ */
public SysWxUserInfo getSysWxUserInfoByPhone(String phone); public SysWxUserInfo getSysWxUserInfoByPhone(String phone);
/**
* 根据openid移除对应绑定的cusId
* @param openid
* @return
*/
public int removeCusIdByOpenId(String openid);
} }

View File

@ -198,11 +198,33 @@ public class SysCustomerServiceImpl implements ISysCustomerService {
if(newCustomer == null || newCustomer.getId() == null || StringUtils.isEmpty(newCustomer.getPhone())){ if(newCustomer == null || newCustomer.getId() == null || StringUtils.isEmpty(newCustomer.getPhone())){
return; return;
} }
//先根据cusId查询是否已经绑定过微信用户
SysWxUserInfo cusIdWxUserInfo = sysWxUserInfoService.selectSysWxUserInfoByCusId(newCustomer.getId());
//根据手机号查询微信用户记录 //根据手机号查询微信用户记录
SysWxUserInfo wxUserInfo = sysWxUserInfoService.getSysWxUserInfoByPhone(newCustomer.getPhone()); SysWxUserInfo phoneWxUserInfo = sysWxUserInfoService.getSysWxUserInfoByPhone(newCustomer.getPhone());
if(wxUserInfo != null && (wxUserInfo.getCusId() == null || wxUserInfo.getCusId().longValue() != newCustomer.getId())){ if(cusIdWxUserInfo != null) {
wxUserInfo.setCusId(newCustomer.getId()); if(phoneWxUserInfo != null){
sysWxUserInfoService.updateSysWxUserInfo(wxUserInfo); if(!cusIdWxUserInfo.getOpenid().equals(phoneWxUserInfo.getOpenid())){
//解绑之前记录
sysWxUserInfoService.removeCusIdByOpenId(cusIdWxUserInfo.getOpenid());
//更新
SysWxUserInfo param = new SysWxUserInfo();
param.setOpenid(phoneWxUserInfo.getOpenid());
param.setCusId(newCustomer.getId());
sysWxUserInfoService.updateSysWxUserInfo(param);
}
}else{
//解绑之前记录
sysWxUserInfoService.removeCusIdByOpenId(cusIdWxUserInfo.getOpenid());
}
}else{
if(phoneWxUserInfo != null){
//更新
SysWxUserInfo param = new SysWxUserInfo();
param.setOpenid(phoneWxUserInfo.getOpenid());
param.setCusId(newCustomer.getId());
sysWxUserInfoService.updateSysWxUserInfo(param);
}
} }
} }
} }

View File

@ -106,4 +106,13 @@ public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService {
public SysWxUserInfo getSysWxUserInfoByPhone(String phone){ public SysWxUserInfo getSysWxUserInfoByPhone(String phone){
return sysWxUserInfoMapper.getSysWxUserInfoByPhone(phone); return sysWxUserInfoMapper.getSysWxUserInfoByPhone(phone);
} }
/**
* 根据openid移除对应绑定的cusId
* @param openid
* @return
*/
public int removeCusIdByOpenId(String openid){
return sysWxUserInfoMapper.removeCusIdByOpenId(openid);
}
} }

View File

@ -42,12 +42,17 @@
<if test="endTime != null and endTime != ''">AND date_format(order_time,'%y%m%d') &lt;= <if test="endTime != null and endTime != ''">AND date_format(order_time,'%y%m%d') &lt;=
date_format(${endTime},'%y%m%d') date_format(${endTime},'%y%m%d')
</if> </if>
<!-- 因为体验单、售中单都存在售中,所以售中的提成金额只计算售中单的,不计算体验单 -->
<if test="postCode != null and postCode == 'on_sale_id'">
and order_type = 3
</if>
GROUP BY ${column} GROUP BY ${column}
</sql> </sql>
<select id="selectSysCommisionDetail" parameterType="SysCommision" resultMap="SysCommisionResult"> <select id="selectSysCommisionDetail" parameterType="SysCommision" resultMap="SysCommisionResult">
SELECT * FROM view_user_post pa SELECT * FROM view_user_post pa
JOIN ( JOIN (
<if test="postId == null or postId == 0">
<include refid="groupAmountVo"> <include refid="groupAmountVo">
<property name="column" value="pre_sale_id"/> <property name="column" value="pre_sale_id"/>
<property name="reviewStatus" value="#{reviewStatus}"/> <property name="reviewStatus" value="#{reviewStatus}"/>
@ -56,6 +61,22 @@
<property name="postId" value="5"/> <property name="postId" value="5"/>
</include> </include>
UNION UNION
<include refid="groupAmountVo">
<property name="column" value="push_pre_sale_id"/>
<property name="reviewStatus" value="#{reviewStatus}"/>
<property name="beginTime" value="#{beginTime}"/>
<property name="endTime" value="#{endTime}"/>
<property name="postId" value="18"/>
</include>
UNION
<include refid="groupAmountVo">
<property name="column" value="on_sale_id"/>
<property name="reviewStatus" value="#{reviewStatus}"/>
<property name="beginTime" value="#{beginTime}"/>
<property name="endTime" value="#{endTime}"/>
<property name="postId" value="16"/>
</include>
UNION
<include refid="groupAmountVo"> <include refid="groupAmountVo">
<property name="column" value="after_sale_id"/> <property name="column" value="after_sale_id"/>
<property name="reviewStatus" value="#{reviewStatus}"/> <property name="reviewStatus" value="#{reviewStatus}"/>
@ -111,9 +132,19 @@
<property name="endTime" value="#{endTime}"/> <property name="endTime" value="#{endTime}"/>
<property name="postId" value="8"/> <property name="postId" value="8"/>
</include> </include>
</if>
<if test="postId != null and postId > 0">
<include refid="groupAmountVo">
<property name="column" value="${postCode}"/>
<property name="reviewStatus" value="#{reviewStatus}"/>
<property name="beginTime" value="#{beginTime}"/>
<property name="endTime" value="#{endTime}"/>
<property name="postId" value="${postId}"/>
</include>
</if>
) AS a USING(user_id, post_id) ) AS a USING(user_id, post_id)
<where> <where>
<if test="postId != null and postId != ''">and post_id = #{postId}</if> <!--<if test="postId != null and postId != ''">and post_id = #{postId}</if>-->
<if test="userId != null and userId != ''">and user_id = #{userId}</if> <if test="userId != null and userId != ''">and user_id = #{userId}</if>
<if test="userIds != null"> <if test="userIds != null">
and user_id in and user_id in
@ -122,6 +153,7 @@
</foreach> </foreach>
</if> </if>
</where> </where>
order by user_id asc
</select> </select>
<sql id="selectSysCommisionVo"> <sql id="selectSysCommisionVo">

View File

@ -135,4 +135,9 @@
where phone = #{phone} order by create_time desc limit 1 where phone = #{phone} order by create_time desc limit 1
</select> </select>
<!-- 根据openid移除绑定的cusId -->
<update id="removeCusIdByOpenId" parameterType="String">
update sys_wx_user_info set cus_id = null where openid = #{openid}
</update>
</mapper> </mapper>

View File

@ -129,7 +129,7 @@
<el-select v-model="form.pushPreSaleId" placeholder="请选择" filterable <el-select v-model="form.pushPreSaleId" placeholder="请选择" filterable
clearable> clearable>
<el-option <el-option
v-for="dict in preSaleIdOptions" v-for="dict in pushPreSaleIdOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="parseInt(dict.dictValue)" :value="parseInt(dict.dictValue)"
@ -536,6 +536,8 @@ export default {
"operatorIdOptions", "operatorIdOptions",
// //
"operatorAssisIdOptions", "operatorAssisIdOptions",
//
"pushPreSaleIdOptions"
]), ]),
}, },
methods: { methods: {

View File

@ -107,7 +107,7 @@
<el-form-item label="售前推送" prop="preSaleId"> <el-form-item label="售前推送" prop="preSaleId">
<el-select v-model="form.pushPreSaleId" placeholder="请选择"> <el-select v-model="form.pushPreSaleId" placeholder="请选择">
<el-option <el-option
v-for="dict in preSaleIdOptions" v-for="dict in pushPreSaleIdOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="parseInt(dict.dictValue)" :value="parseInt(dict.dictValue)"
@ -465,6 +465,8 @@ export default {
"operatorIdOptions", "operatorIdOptions",
// //
"operatorAssisIdOptions", "operatorAssisIdOptions",
//
"pushPreSaleIdOptions"
]), ]),
}, },
methods: { methods: {

View File

@ -24,6 +24,7 @@ const getters = {
plannerIdOptions: state => state.global.plannerIdOptions, plannerIdOptions: state => state.global.plannerIdOptions,
plannerAssisIdOptions: state => state.global.plannerAssisIdOptions, plannerAssisIdOptions: state => state.global.plannerAssisIdOptions,
operatorIdOptions: state => state.global.operatorIdOptions, operatorIdOptions: state => state.global.operatorIdOptions,
operatorAssisIdOptions: state => state.global.operatorAssisIdOptions operatorAssisIdOptions: state => state.global.operatorAssisIdOptions,
pushPreSaleIdOptions: state => state.global.pushPreSaleIdOptions
}; };
export default getters; export default getters;

View File

@ -9,7 +9,8 @@ const oriState = {
plannerIdOptions: [], plannerIdOptions: [],
plannerAssisIdOptions: [], plannerAssisIdOptions: [],
operatorIdOptions: [], operatorIdOptions: [],
operatorAssisIdOptions: [] operatorAssisIdOptions: [],
pushPreSaleIdOptions:[]
}; };
const mutations = { const mutations = {
@ -47,7 +48,8 @@ const actions = {
plannerIdOptions: options["planner"] || [], plannerIdOptions: options["planner"] || [],
plannerAssisIdOptions: options["planner_assis"] || [], plannerAssisIdOptions: options["planner_assis"] || [],
operatorIdOptions: options["operator"] || [], operatorIdOptions: options["operator"] || [],
operatorAssisIdOptions: options["operator_assis"] || [] operatorAssisIdOptions: options["operator_assis"] || [],
pushPreSaleIdOptions: options["push_pre_sale"] || [],
}); });
} }
}; };