|
|
|
@ -233,20 +233,10 @@ public class CustomerService {
|
|
|
|
|
*/
|
|
|
|
|
private void handleAddCustomer(TurnBackDTO turnBackDTOS) throws Exception {
|
|
|
|
|
log.info(new Gson().toJson(turnBackDTOS));
|
|
|
|
|
// OpCustomer opCustomer = null;
|
|
|
|
|
Long opCustomerId = 0L;
|
|
|
|
|
if (StringUtils.isBlank(turnBackDTOS.getWxData().getUnionId()) && StringUtils.isNotBlank(turnBackDTOS.getWxData().getUserId())) {
|
|
|
|
|
if (StringUtils.isNotBlank(turnBackDTOS.getWxData().getUserId())) {
|
|
|
|
|
//此时说明是企业微信扫码添加
|
|
|
|
|
// QueryWrapper<OpCustomer> customerWrapper = new QueryWrapper<>();
|
|
|
|
|
// customerWrapper.eq("external_userid", turnBackDTOS.getWxData().getUserId()).last("limit 1");
|
|
|
|
|
opCustomerId = redisUtil.getExternalUserId(turnBackDTOS.getWxData().getUserId());
|
|
|
|
|
// opCustomer = opCustomerDOMapper.selectOne(customerWrapper);
|
|
|
|
|
} else if (StringUtils.isNotBlank(turnBackDTOS.getWxData().getUnionId()) && StringUtils.isNotBlank(turnBackDTOS.getWxData().getUserId())) {
|
|
|
|
|
//客户信息
|
|
|
|
|
// QueryWrapper<OpCustomer> customerWrapper = new QueryWrapper<>();
|
|
|
|
|
// customerWrapper.eq("wechat_uni_id", turnBackDTOS.getWxData().getUnionId()).last("limit 1");
|
|
|
|
|
opCustomerId = redisUtil.getExternalUserId(turnBackDTOS.getWxData().getUserId());
|
|
|
|
|
// opCustomer = opCustomerDOMapper.selectOne(customerWrapper);
|
|
|
|
|
} else {
|
|
|
|
|
log.error("turn back error: " + turnBackDTOS.toString());
|
|
|
|
|
return;
|
|
|
|
@ -325,6 +315,7 @@ public class CustomerService {
|
|
|
|
|
//不存在
|
|
|
|
|
try {
|
|
|
|
|
opCustomerDOMapper.insert(insertCustomer);
|
|
|
|
|
redisUtil.setExternalUserId(insertCustomer.getExternalUserid(),insertCustomer.getId());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(insertCustomer.toString(), e);
|
|
|
|
|
return;
|
|
|
|
@ -459,11 +450,7 @@ public class CustomerService {
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void sellerCustomerRelation(OpCustomer opCustomer, Date joinTime, long shopId, long sellerId) {
|
|
|
|
|
// QueryWrapper<OpSellerCustomerRelation> wrapper1 = new QueryWrapper<>();
|
|
|
|
|
//一个客户只能添加一个店的店长微信,所以根据店铺判断即可
|
|
|
|
|
// wrapper1.eq("customer_id", opCustomer.getId()).eq("store_id", shopId).eq("user_id", sellerId).last("limit 1");
|
|
|
|
|
Object result = redisUtil.getCustomerId(opCustomer.getId() , sellerId, shopId);
|
|
|
|
|
// OpSellerCustomerRelation opSellerCustomerRelation = opSellerCustomerRelationDOMapper.selectOne(wrapper1);
|
|
|
|
|
if (null == result) {
|
|
|
|
|
//不存在就添加
|
|
|
|
|
OpSellerCustomerRelation insertRelation = new OpSellerCustomerRelation();
|
|
|
|
@ -475,10 +462,6 @@ public class CustomerService {
|
|
|
|
|
insertRelation.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
insertRelation.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
insertRelation.setCpUserId(opCustomer.getCpUserId());
|
|
|
|
|
//判断是否有效
|
|
|
|
|
// QueryWrapper<OpSellerCustomerRelation> wrapper = new QueryWrapper<>();
|
|
|
|
|
// wrapper.eq("customer_id", opCustomer.getId()).last("limit 1");
|
|
|
|
|
// OpSellerCustomerRelation op = opSellerCustomerRelationDOMapper.selectOne(wrapper);
|
|
|
|
|
if (isVailCustomer(opCustomer.getId())) {
|
|
|
|
|
//有效
|
|
|
|
|
insertRelation.setType(1);
|
|
|
|
@ -512,9 +495,6 @@ public class CustomerService {
|
|
|
|
|
insertRelation.setCpUserId(opCustomer.getCpUserId());
|
|
|
|
|
|
|
|
|
|
//判断是否有效
|
|
|
|
|
// QueryWrapper<OpSellerCustomerRelation> wrapper = new QueryWrapper<>();
|
|
|
|
|
// wrapper.eq("customer_id", opCustomer.getId()).last("limit 1");
|
|
|
|
|
// OpSellerCustomerRelation op = opSellerCustomerRelationDOMapper.selectOne(wrapper);
|
|
|
|
|
if (isVailCustomer(opCustomer.getId())) {
|
|
|
|
|
//有效
|
|
|
|
|
insertRelation.setType(1);
|
|
|
|
|