Commit e4141454 by zhiheng.zhang

Merge branch 'feature/20210224-订单添加备注信息-张志恒'

parents fe9c74d2 a206df90
......@@ -931,49 +931,53 @@ public class OrderServiceImpl implements Orderservice {
Long pickUpTime = 0L; //预计
Integer totalSumTime = 0;
String progress = "0" ; //进度
JSONObject storeJsonObject = JSONObject.parseObject(storeResponseDto.getConfiguration());
StoreResponse.Configuration configuration = storeJsonObject.toJavaObject(StoreResponse.Configuration.class);
log.info("StoreResponse.Configuration {}",JSONObject.toJSONString(configuration));
Integer orderProgressBarStatus = configuration.getOrderProgressBarStatus();; //默认关闭
//订单状态为已接单并且无售后单展示进度条
if(OrderStatus.RECEIPT.getCode() == orderBean.getStatus() && null == orderBean.getAfterSalesOrderResp() && null != orderProgressBarStatus && null != configuration.getTurnOnTimeOfMaking()) {
try {
// 查询订单的排队人数
QueryLineUpOrderReq queryLineUpOrderReq = new QueryLineUpOrderReq();
queryLineUpOrderReq.setPartnerId(orderBean.getCompanyId());
queryLineUpOrderReq.setStoreId(orderBean.getShopId());
queryLineUpOrderReq.setStartTime(DateUtil.addHours(new Date(orderBean.getGmtCreate()), -24).getTime());
queryLineUpOrderReq.setEndTime(orderBean.getGmtCreate());
// 取餐排队人数查询代码去除
QueryLineUpResponse response = orderCenterSdkService.queryLineUpOrder(queryLineUpOrderReq);;
if (RESPONSE_SUCCESS_CODE.equals(response.getErrcode())) {
if (null == response.getOrderCodes()) {
progress = "100";
returnWords = "";
} else {
List<String> orderCodeList = response.getOrderCodes();
if (null != orderCodeList && orderCodeList.size() > 0) {
returnWords += "前方还有 " + orderCodeList.size() + " 单";
//开启制作时间 1 :是 , 2 :否"
if (1 != configuration.getTurnOnTimeOfMaking()) {
totalSumTime = orderCodeList.size() * AutoOrderConfigTime.getTime(configuration.getAutoSelfmentionTakeOrderWorkflowFinishTime()); //分钟
} else {
Integer goodsAvgTimeOfMaking = (null == configuration.getGoodsAvgTimeOfMaking() || 0 == configuration.getGoodsAvgTimeOfMaking())? 5 : configuration.getGoodsAvgTimeOfMaking();
productSum = orderCodeList.stream().mapToInt(product -> Integer.parseInt(product.split("-")[1])).sum();
totalSumTime = productSum * goodsAvgTimeOfMaking;
returnWords += " / " + productSum + " 件";
Integer orderProgressBarStatus = 2;
StoreResponse.Configuration configuration = storeResponseDto.getStoreConfig();
if(null != configuration) {
log.info("StoreResponse.Configuration {}", JSONObject.toJSONString(configuration));
orderProgressBarStatus = configuration.getOrderProgressBarStatus();
; //默认关闭
//订单状态为已接单并且无售后单展示进度条
if (OrderStatus.RECEIPT.getCode() == orderBean.getStatus() && null == orderBean.getAfterSalesOrderResp() && null != orderProgressBarStatus && null != configuration.getTurnOnTimeOfMaking()) {
try {
// 查询订单的排队人数
QueryLineUpOrderReq queryLineUpOrderReq = new QueryLineUpOrderReq();
queryLineUpOrderReq.setPartnerId(orderBean.getCompanyId());
queryLineUpOrderReq.setStoreId(orderBean.getShopId());
queryLineUpOrderReq.setStartTime(DateUtil.addHours(new Date(orderBean.getGmtCreate()), -24).getTime());
queryLineUpOrderReq.setEndTime(orderBean.getGmtCreate());
// 取餐排队人数查询代码去除
QueryLineUpResponse response = orderCenterSdkService.queryLineUpOrder(queryLineUpOrderReq);
;
if (RESPONSE_SUCCESS_CODE.equals(response.getErrcode())) {
if (null == response.getOrderCodes()) {
progress = "100";
returnWords = "";
} else {
List<String> orderCodeList = response.getOrderCodes();
if (null != orderCodeList && orderCodeList.size() > 0) {
returnWords += "前方还有 " + orderCodeList.size() + " 单";
//开启制作时间 1 :是 , 2 :否"
if (1 != configuration.getTurnOnTimeOfMaking()) {
totalSumTime = orderCodeList.size() * AutoOrderConfigTime.getTime(configuration.getAutoSelfmentionTakeOrderWorkflowFinishTime()); //分钟
} else {
Integer goodsAvgTimeOfMaking = (null == configuration.getGoodsAvgTimeOfMaking() || 0 == configuration.getGoodsAvgTimeOfMaking()) ? 5 : configuration.getGoodsAvgTimeOfMaking();
productSum = orderCodeList.stream().mapToInt(product -> Integer.parseInt(product.split("-")[1])).sum();
totalSumTime = productSum * goodsAvgTimeOfMaking;
returnWords += " / " + productSum + " 件";
}
pickUpTime = DateUtil.addMinutes(new Date(orderBean.getGmtAccept()), totalSumTime).getTime();
Date date = new Date(pickUpTime);
returnWords += ",预计 " + (String.valueOf(date.getHours()).length() == 1 ? "0" + (String.valueOf(date.getHours())) : date.getHours()) + ":" + (String.valueOf(date.getMinutes()).length() == 1 ? "0" + (String.valueOf(date.getMinutes())) : date.getMinutes()) + " 可取餐";
//制餐进度(当前时间-接单时间)/总时长(制餐时长)x100%
BigDecimal progressB = new BigDecimal(DateUtil.diffMinute(new Date(orderBean.getGmtAccept()), new Date())).divide(new BigDecimal(totalSumTime), 2, BigDecimal.ROUND_HALF_UP);
progress = progressB.compareTo(new BigDecimal(1)) == 1 ? "100" : progressB.multiply(new BigDecimal(100)).toString();
}
pickUpTime = DateUtil.addMinutes(new Date(orderBean.getGmtAccept()), totalSumTime).getTime();
Date date = new Date(pickUpTime);
returnWords += ",预计 " + (String.valueOf( date.getHours()).length()==1 ? "0"+(String.valueOf( date.getHours())) : date.getHours()) + ":" + (String.valueOf(date.getMinutes()).length()==1 ? "0"+(String.valueOf(date.getMinutes())) : date.getMinutes()) + " 可取餐";
//制餐进度(当前时间-接单时间)/总时长(制餐时长)x100%
BigDecimal progressB = new BigDecimal(DateUtil.diffMinute(new Date(orderBean.getGmtAccept()), new Date())).divide(new BigDecimal(totalSumTime), 2, BigDecimal.ROUND_HALF_UP);
progress = progressB.compareTo(new BigDecimal(1)) == 1 ? "100" : progressB.multiply(new BigDecimal(100)).toString();
}
}
} catch (Exception e) {
log.error("get returnWords error :{},StoreResponse.Configuration:{}", e.getMessage(), JSONObject.toJSONString(configuration));
}
} catch (Exception e) {
log.error("get returnWords error :{},StoreResponse.Configuration:{}", e.getMessage(),JSONObject.toJSONString(configuration));
}
}
orderBean.setProgress(String.valueOf(progress));
......
......@@ -46,4 +46,9 @@ public class RedisKeyConstant {
* 新版支付白名单在redis的key前缀
*/
public final static String SAAS_MICRO_PAYMENT_PARTNER = "saas:micro:payment:partner:";
/**
* wxapp_config配置表
*/
public final static String KGD_ORDER_OPEN_STORE_IAPP_WXAPP_CONFIG_WXAPPID_ = "kgd:order:open_store_iapp_wxapp_config:wxappid_";
}
......@@ -19,6 +19,7 @@ import cn.freemud.entities.dto.GetMemberInfoRequestDto;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.OrderChannelType;
import cn.freemud.enums.ResponseResult;
import cn.freemud.service.OpenStoreIappWxappConfigService;
import cn.freemud.service.ShoppingCartNewService;
import cn.freemud.service.impl.ShoppingCartMallServiceImpl;
import cn.freemud.service.impl.ShoppingCartMealServiceImpl;
......@@ -51,6 +52,9 @@ public class ShoppingCartController {
@Autowired
private AssortmentCustomerInfoManager customerInfoManager;
@Autowired
private OpenStoreIappWxappConfigService openStoreIappWxappConfigService;
/**
* 从微信卡券向购物车中添加商品
*/
......@@ -187,4 +191,13 @@ public class ShoppingCartController {
return SDKCommonBaseContextWare.getBean(ShoppingCartNewServiceImpl.class).getMemberInfo(request);
}
/**
* 结算页获取是否展示订单那备注配置
*/
@PostMapping(value = "/getOpenStoreIappWxappConfig")
@LogIgnore(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},logMessage = "/getOpenStoreIappWxappConfig")
public BaseResponse getOpenStoreIappWxappConfig(@LogParams @RequestBody OpenStoreIappWxappConfigRequestVo request) {
return openStoreIappWxappConfigService.getOpenStoreIappWxappConfig(request);
}
}
package cn.freemud.entities.db;
import javax.persistence.*;
import java.util.Date;
@Table(name = "open_store_iapp_wxapp_config")
public class OpenStoreIappWxappConfig {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 自定义小程序appid
*/
private String appid;
/**
* 微信小程序appid
*/
@Column(name = "wx_appid")
private String wxAppid;
/**
* 是否允许填写备注文案,0=否,1=是
*/
@Column(name = "take_inside")
private Integer takeInside;
/**
* 到店订单默认文案
*/
@Column(name = "inside_remark")
private String insideRemark;
/**
* 外卖订单默认文案
*/
@Column(name = "take_out_remark")
private String takeOutRemark;
/**
* 创建时间
*/
@Column(name = "gmt_created")
private Date gmtCreated;
/**
* 修改时间
*/
@Column(name = "gmt_modified")
private Date gmtModified;
/**
* @return id
*/
public Long getId() {
return id;
}
/**
* @param id
*/
public void setId(Long id) {
this.id = id;
}
/**
* 获取自定义小程序appid
*
* @return appid - 自定义小程序appid
*/
public String getAppid() {
return appid;
}
/**
* 设置自定义小程序appid
*
* @param appid 自定义小程序appid
*/
public void setAppid(String appid) {
this.appid = appid;
}
/**
* 获取微信小程序appid
*
* @return wx_appid - 微信小程序appid
*/
public String getWxAppid() {
return wxAppid;
}
/**
* 设置微信小程序appid
*
* @param wxAppid 微信小程序appid
*/
public void setWxAppid(String wxAppid) {
this.wxAppid = wxAppid;
}
/**
* 获取是否允许填写备注文案,0=否,1=是
*
* @return take_inside - 是否允许填写备注文案,0=否,1=是
*/
public Integer getTakeInside() {
return takeInside;
}
/**
* 设置是否允许填写备注文案,0=否,1=是
*
* @param takeInside 是否允许填写备注文案,0=否,1=是
*/
public void setTakeInside(Integer takeInside) {
this.takeInside = takeInside;
}
/**
* 获取到店订单默认文案
*
* @return inside_remark - 到店订单默认文案
*/
public String getInsideRemark() {
return insideRemark;
}
/**
* 设置到店订单默认文案
*
* @param insideRemark 到店订单默认文案
*/
public void setInsideRemark(String insideRemark) {
this.insideRemark = insideRemark;
}
/**
* 获取外卖订单默认文案
*
* @return take_out_remark - 外卖订单默认文案
*/
public String getTakeOutRemark() {
return takeOutRemark;
}
/**
* 设置外卖订单默认文案
*
* @param takeOutRemark 外卖订单默认文案
*/
public void setTakeOutRemark(String takeOutRemark) {
this.takeOutRemark = takeOutRemark;
}
/**
* 获取创建时间
*
* @return gmt_created - 创建时间
*/
public Date getGmtCreated() {
return gmtCreated;
}
/**
* 设置创建时间
*
* @param gmtCreated 创建时间
*/
public void setGmtCreated(Date gmtCreated) {
this.gmtCreated = gmtCreated;
}
/**
* 获取修改时间
*
* @return gmt_modified - 修改时间
*/
public Date getGmtModified() {
return gmtModified;
}
/**
* 设置修改时间
*
* @param gmtModified 修改时间
*/
public void setGmtModified(Date gmtModified) {
this.gmtModified = gmtModified;
}
}
\ No newline at end of file
package cn.freemud.entities.vo;
import lombok.Data;
import org.hibernate.validator.constraints.NotEmpty;
@Data
public class OpenStoreIappWxappConfigRequestVo{
@NotEmpty(message = "sessionId不能为空")
private String sessionId;
}
......@@ -222,4 +222,6 @@ public class ShoppingCartGoodsResponseVo extends ShoppingCartGoodsBaseResponseV
* 是否已选择寄杯
*/
private Boolean sendCoupon;
}}
}
}
package cn.freemud.service;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.vo.OpenStoreIappWxappConfigRequestVo;
import cn.freemud.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
public interface OpenStoreIappWxappConfigService {
BaseResponse getOpenStoreIappWxappConfig(OpenStoreIappWxappConfigRequestVo openStoreIappWxappConfigRequestVo);
}
package cn.freemud.service.impl;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.RedisKeyConstant;
import cn.freemud.entities.db.OpenStoreIappWxappConfig;
import cn.freemud.entities.dto.user.GetSessionUserInfoDto;
import cn.freemud.entities.vo.CustomerInfoVo;
import cn.freemud.entities.vo.OpenStoreIappWxappConfigRequestVo;
import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException;
import cn.freemud.redis.RedisCache;
import cn.freemud.service.OpenStoreIappWxappConfigService;
import cn.freemud.service.thirdparty.CustomerApplicationClient;
import cn.freemud.utils.BeanUtil;
import cn.freemud.utils.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class OpenStoreIappWxappConfigServiceImpl implements OpenStoreIappWxappConfigService {
@Autowired
private RedisCache redisCache;
@Autowired
private CustomerApplicationClient customerApplicationClient;
public BaseResponse getOpenStoreIappWxappConfig(OpenStoreIappWxappConfigRequestVo openStoreIappWxappConfigRequestVo){
// 获取用户信息
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(openStoreIappWxappConfigRequestVo.getSessionId());
//缓存为空则初始化为展示备注,默认备注为空,
OpenStoreIappWxappConfig defauleConfig = new OpenStoreIappWxappConfig();
defauleConfig.setTakeInside(1);
defauleConfig.setInsideRemark("");
defauleConfig.setTakeOutRemark("");
OpenStoreIappWxappConfig config;
try {
config = redisCache.hashGet(RedisKeyConstant.KGD_ORDER_OPEN_STORE_IAPP_WXAPP_CONFIG_WXAPPID_, assortmentCustomerInfoVo.getWxAppId());
if (null == config) {
config = new OpenStoreIappWxappConfig();
BeanUtils.copyProperties(config,defauleConfig);
return ResponseUtil.success(config);
}else{
return ResponseUtil.success(config);
}
}catch (Exception e){
//异常打印日常日志,返回默认config
log.error("getOpenStoreIappWxappConfig error {}" ,e.getMessage());
return ResponseUtil.success(defauleConfig);
}
}
private CustomerInfoVo getCustomerInfoVo(String sessionId) {
GetSessionUserInfoDto getSessionUserInfoDto = new GetSessionUserInfoDto();
getSessionUserInfoDto.setIsGetPaid(true);
getSessionUserInfoDto.setSessionId(sessionId);
BaseResponse<CustomerInfoVo> sessionUserInfo = customerApplicationClient.getSessionUserInfo(getSessionUserInfoDto);
if (!ResponseResult.SUCCESS.getCode().equals(sessionUserInfo.getCode()) || sessionUserInfo.getResult() == null) {
throw new ServiceException(ResponseResult.NOT_LOGIN);
}
return sessionUserInfo.getResult();
}
}
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