Commit 395fbc18 by 王祖波

建联转换订单

parent 08c1d755
package com.gic.haoban.manage.api.qdto.contact;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
public class ContactOrderQDTO implements Serializable {
private static final long serialVersionUID = 973688857967269974L;
/**
* 会员id
*/
private String memberId;
/**
* 企业id
*/
private String enterpriseId;
/**
* 订单id
*/
private String orderId;
/**
* 是否线上订单
*/
private boolean isOnlineOrder;
public String getMemberId() {
return memberId;
}
public void setMemberId(String memberId) {
this.memberId = memberId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public boolean isOnlineOrder() {
return isOnlineOrder;
}
public void setOnlineOrder(boolean onlineOrder) {
isOnlineOrder = onlineOrder;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.service.contact;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.qdto.contact.ContactOrderQDTO;
public interface ContactOrderApiService {
/**
* 保存建联转化订单
* @param contactOrderQDTO
*/
ServiceResponse<Void> saveContactOrder(ContactOrderQDTO contactOrderQDTO);
}
......@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.dao.mapper.contact;
import com.gic.haoban.manage.service.entity.contact.TabContactLog;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
......@@ -34,7 +35,7 @@ public interface TabContactLogMapper {
* @param clerkId
* @return
*/
TabContactLog queryLastLog(@Param("memberId")String memberId,@Param("clerkId")String clerkId);
TabContactLog queryLastLog(@Param("memberId")String memberId, @Param("clerkId")String clerkId, @Param("beginTime")Date beginTime);
/**
* 统计总行数
......
......@@ -31,7 +31,7 @@ public class TabContactOrder implements Serializable {
/**
* 实付金额
*/
private BigDecimal paidAmount;
private Double paidAmount;
/**
* 商品数量
*/
......@@ -129,11 +129,11 @@ public class TabContactOrder implements Serializable {
this.orderNumber = orderNumber;
}
public BigDecimal getPaidAmount() {
public Double getPaidAmount() {
return paidAmount;
}
public void setPaidAmount(BigDecimal paidAmount) {
public void setPaidAmount(Double paidAmount) {
this.paidAmount = paidAmount;
}
......
......@@ -3,26 +3,39 @@ package com.gic.haoban.manage.service.service.contact;
import com.gic.haoban.manage.api.qdto.contact.ContactLogQDTO;
import com.gic.haoban.manage.service.entity.contact.TabContactLog;
import java.util.Date;
public interface ContactLogService {
/**
* 保存建联记录
*
* @param qdto
*/
void saveContactLog(ContactLogQDTO qdto);
/**
* 清除建联状态
*
* @param memberId
* @param clearType 1 消费清除 2 换绑主导购
*/
void clearContactLog(String memberId,Integer clearType);
void clearContactLog(String memberId, Integer clearType);
/**
* 获取最近一条有效建联记录
*
* @param memberId
* @return
*/
TabContactLog getClerkContactTime(String memberId);
/**
* 根据时间获取最近一条建联记录
* @param memberId
* @param beginTime
* @return
*/
TabContactLog getLastByTime(String memberId, Date beginTime);
}
package com.gic.haoban.manage.service.service.contact;
import com.gic.order.api.dto.resp.OrderInfoResp;
public interface ContactOrderService {
/**
* 保存建联转化订单
* @param orderInfoResp
*/
void saveContactOrder(OrderInfoResp orderInfoResp);
}
......@@ -59,7 +59,7 @@ public class ContactLogServiceImpl implements ContactLogService {
Integer contactCycle = 1;
// 建联周期 14天内同周期/14天以上周期+1
Integer contactCycleFirst = Constant.FLAG_TRUE;
TabContactLog lastContactLog = contactLogMapper.queryLastLog(memberId, clerkId);
TabContactLog lastContactLog = contactLogMapper.queryLastLog(memberId, clerkId,null);
if (lastContactLog != null) {
Date contactTime = lastContactLog.getContactTime();
if (DateUtil.between(date, contactTime, DateUnit.SECOND) > 14 * 24 * 60 * 60) {
......@@ -101,7 +101,7 @@ public class ContactLogServiceImpl implements ContactLogService {
@Override
public void clearContactLog(String memberId,Integer clearType) {
logger.info("清除建联状态:{},clearType:{}", memberId, clearType);
TabContactLog lastContactLog = contactLogMapper.queryLastLog(memberId, null);
TabContactLog lastContactLog = contactLogMapper.queryLastLog(memberId, null,null);
if (lastContactLog == null) {
return;
}
......@@ -117,7 +117,7 @@ public class ContactLogServiceImpl implements ContactLogService {
@Override
public TabContactLog getClerkContactTime(String memberId) {
TabContactLog lastContactLog = contactLogMapper.queryLastLog(memberId, null);
TabContactLog lastContactLog = contactLogMapper.queryLastLog(memberId, null,null);
if (lastContactLog == null) {
return null;
}
......@@ -140,4 +140,9 @@ public class ContactLogServiceImpl implements ContactLogService {
}
return lastContactLog;
}
@Override
public TabContactLog getLastByTime(String memberId, Date beginTime) {
return contactLogMapper.queryLastLog(memberId, null,beginTime);
}
}
package com.gic.haoban.manage.service.service.contact.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.gic.clerk.api.service.ClerkService;
import com.gic.enterprise.api.enums.PlatformChannelEnum;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.manage.service.dao.mapper.contact.TabContactLogMapper;
import com.gic.haoban.manage.service.dao.mapper.contact.TabContactOrderMapper;
import com.gic.haoban.manage.service.entity.contact.TabContactLog;
import com.gic.haoban.manage.service.entity.contact.TabContactOrder;
import com.gic.haoban.manage.service.service.contact.ContactFollowService;
import com.gic.haoban.manage.service.service.contact.ContactLogService;
import com.gic.haoban.manage.service.service.contact.ContactOrderService;
import com.gic.member.api.service.MemberService;
import com.gic.order.api.dto.resp.OrderInfoResp;
import com.gic.store.goods.service.StoreGoodsService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Objects;
@Service("contactOrderService")
public class ContactOrderServiceImpl implements ContactOrderService {
private static final Logger logger = LogManager.getLogger(ContactOrderService.class);
@Autowired
private TabContactOrderMapper contactOrderMapper;
@Autowired
private ContactLogService contactLogService;
@Autowired
private StoreGoodsService storeGoodsService;
@Autowired
private ClerkService clerkService;
@Autowired
private StoreService storeService;
@Autowired
private MemberService memberService;
@Override
public void saveContactOrder(OrderInfoResp orderInfoResp) {
Integer orderType = orderInfoResp.getOrderType();
PlatformChannelEnum platformChannelEnum = PlatformChannelEnum.getEnumByOldOrderType(orderType);
if (platformChannelEnum == null) {
return;
}
Date receiptsDate = orderInfoResp.getReceiptsDate();
Date contactBeginTime = null;
String channelCode = platformChannelEnum.getChannelCode();
// 1 线上; 2 线下
Integer channelType = null;
if (Objects.equals(PlatformChannelEnum.C_POS.getChannelCode(), channelCode)) {
channelType = 2;
contactBeginTime = DateUtil.offsetDay(receiptsDate, -7);
}else {
channelType = 1;
contactBeginTime = DateUtil.offsetDay(receiptsDate, -1);
}
TabContactLog lastContactLog = contactLogService.getLastByTime(orderInfoResp.getMemberId(), contactBeginTime);
if (lastContactLog == null) {
return;
}
logger.info("建联转化订单建联信息:{}", JSON.toJSONString(lastContactLog));
TabContactOrder contactOrder = new TabContactOrder();
contactOrder.setOrderId(orderInfoResp.getOrderId());
contactOrder.setMemberId(orderInfoResp.getMemberId());
contactOrder.setOrderNumber(orderInfoResp.getOrderNo());
contactOrder.setPaidAmount(orderInfoResp.getPayAmount());
contactOrder.setProductCount(orderInfoResp.getGoodsCount());
contactOrder.setPayTime(orderInfoResp.getReceiptsDate());
contactOrder.setReceiptsDate(orderInfoResp.getReceiptsDate());
contactOrder.setChannelCode(channelCode);
contactOrder.setChannelType(channelType);
contactOrder.setClerkId(lastContactLog.getClerkId());
contactOrder.setClerkCode(lastContactLog.getClerkCode());
contactOrder.setStoreId(lastContactLog.getStoreId());
contactOrder.setContactLogId(lastContactLog.getLogId());
contactOrder.setContactTime(lastContactLog.getContactTime());
contactOrder.setPotentialTime(lastContactLog.getPotentialTime());
contactOrder.setEnterpriseId(lastContactLog.getEnterpriseId());
contactOrderMapper.insert(contactOrder);
}
}
package com.gic.haoban.manage.service.service.out.impl.contact;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.manage.api.dto.contact.ContactLogDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactOrderQDTO;
import com.gic.haoban.manage.api.service.contact.ContactLogApiService;
import com.gic.haoban.manage.api.service.contact.ContactOrderApiService;
import com.gic.haoban.manage.service.entity.contact.TabContactLog;
import com.gic.haoban.manage.service.service.contact.ContactLogService;
import com.gic.haoban.manage.service.service.contact.ContactOrderService;
import com.gic.order.api.dto.resp.OrderInfoResp;
import com.gic.order.api.service.member.MemberOrderReadApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by wangzubo on 2022/11/1.
*/
@Service("contactOrderApiService")
public class ContactOrderApiServiceImpl implements ContactOrderApiService {
@Autowired
private ContactOrderService contactOrderService;
@Autowired
private MemberOrderReadApiService memberOrderReadApiService;
@Override
public ServiceResponse<Void> saveContactOrder(ContactOrderQDTO contactOrderQDTO) {
String enterpriseId = contactOrderQDTO.getEnterpriseId();
String memberId = contactOrderQDTO.getMemberId();
String orderId = contactOrderQDTO.getOrderId();
boolean isOnlineOrder = contactOrderQDTO.isOnlineOrder();
ServiceResponse<OrderInfoResp> serviceResponse =
memberOrderReadApiService.getOrder(enterpriseId, memberId, orderId, isOnlineOrder);
if (!serviceResponse.isSuccess() || serviceResponse.getResult() == null) {
return ServiceResponse.success();
}
OrderInfoResp result = serviceResponse.getResult();
contactOrderService.saveContactOrder(result);
return ServiceResponse.success();
}
}
......@@ -145,6 +145,7 @@
<dubbo:service interface="com.gic.haoban.manage.api.service.role.HaobanRoleApiService" ref="haobanRoleApiServiceImpl"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.contact.ContactFollowApiService" ref="contactFollowApiService"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.contact.ContactLogApiService" ref="contactLogApiService"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.contact.ContactOrderApiService" ref="contactOrderApiService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.DepartmentService" id="gicDepartmentService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxDepartmentApiService"
......
......@@ -45,6 +45,9 @@
<if test="clerkId!=null and clerkId!=''">
and clerk_id = #{clerkId}
</if>
<if test="beginTime!=null ">
and contact_time >= #{beginTime}
</if>
order by contact_time desc,log_id desc limit 1
</select>
......
......@@ -66,8 +66,8 @@
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tab_contact_order (order_id, member_id, order_number, paid_amount, product_count, goods_info, pay_time, receipts_date, channel_code, channel_type, clerk_id, clerk_code, store_id, contact_log_id, contact_time, potential_time, delete_flag, enterprise_id, create_time, update_time)
VALUES (#{orderId}, #{memberId}, #{orderNumber}, #{paidAmount}, #{productCount}, #{goodsInfo}, #{payTime}, #{receiptsDate}, #{channelCode}, #{channelType}, #{clerkId}, #{clerkCode}, #{storeId}, #{contactLogId}, #{contactTime}, #{potentialTime}, #{deleteFlag}, #{enterpriseId}, #{createTime}, #{updateTime})
INSERT INTO tab_contact_order (order_id, member_id, order_number, paid_amount, product_count, goods_info, pay_time, receipts_date, channel_code, channel_type, clerk_id, clerk_code, store_id, contact_log_id, contact_time, potential_time, enterprise_id)
VALUES (#{orderId}, #{memberId}, #{orderNumber}, #{paidAmount}, #{productCount}, #{goodsInfo}, #{payTime}, #{receiptsDate}, #{channelCode}, #{channelType}, #{clerkId}, #{clerkCode}, #{storeId}, #{contactLogId}, #{contactTime}, #{potentialTime}, #{enterpriseId})
</insert>
<update id="update">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment