Commit 8cce065b by ping.wu

下单获取用户信息修改

parent d9011769
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
<dependency> <dependency>
<artifactId>assortment-data-manager</artifactId> <artifactId>assortment-data-manager</artifactId>
<groupId>com.freemud.sdk.api.assortment</groupId> <groupId>com.freemud.sdk.api.assortment</groupId>
<version>3.5.RELEASE</version> <version>4.1.3.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.freemud.commons</groupId> <groupId>cn.freemud.commons</groupId>
......
...@@ -1931,133 +1931,133 @@ public class OrderAdapter { ...@@ -1931,133 +1931,133 @@ public class OrderAdapter {
return OldOrderAccountType.BUYM_SENDN; return OldOrderAccountType.BUYM_SENDN;
} }
public QueryOrderAccountType getQueryOrderAccountType(Integer activityType) { // public QueryOrderAccountType getQueryOrderAccountType(Integer activityType) {
if (ActivityTypeEnum.TYPE_11.getCode().equals(activityType) || ActivityTypeEnum.TYPE_12.getCode().equals(activityType)) { // if (ActivityTypeEnum.TYPE_11.getCode().equals(activityType) || ActivityTypeEnum.TYPE_12.getCode().equals(activityType)) {
return QueryOrderAccountType.BUY_DISCOUNT; // return QueryOrderAccountType.BUY_DISCOUNT;
} // }
if (ActivityTypeEnum.TYPE_3.getCode().equals(activityType)) { // if (ActivityTypeEnum.TYPE_3.getCode().equals(activityType)) {
return QueryOrderAccountType.COUPON; // return QueryOrderAccountType.COUPON;
} // }
if (ActivityTypeEnum.TYPE_2.getCode().equals(activityType)) { // if (ActivityTypeEnum.TYPE_2.getCode().equals(activityType)) {
return QueryOrderAccountType.DISCOUNT_AMOUNT; // return QueryOrderAccountType.DISCOUNT_AMOUNT;
} // }
if (ActivityTypeEnum.TYPE_81.getCode().equals(activityType)) { // if (ActivityTypeEnum.TYPE_81.getCode().equals(activityType)) {
return QueryOrderAccountType.PREMIUM_EXCHANGE; // return QueryOrderAccountType.PREMIUM_EXCHANGE;
} // }
if (ActivityTypeEnum.TYPE_32.getCode().equals(activityType)) { // if (ActivityTypeEnum.TYPE_32.getCode().equals(activityType)) {
return QueryOrderAccountType.PRODUCT_COUPON; // return QueryOrderAccountType.PRODUCT_COUPON;
} // }
if (ActivityTypeEnum.TYPE_31.getCode().equals(activityType)) { // if (ActivityTypeEnum.TYPE_31.getCode().equals(activityType)) {
return QueryOrderAccountType.DISCOUNT_COUPON; // return QueryOrderAccountType.DISCOUNT_COUPON;
} // }
if (ActivityTypeEnum.TYPE_PACKAGE.getCode().equals(activityType)) { // if (ActivityTypeEnum.TYPE_PACKAGE.getCode().equals(activityType)) {
return QueryOrderAccountType.PACK_AMOUNT; // return QueryOrderAccountType.PACK_AMOUNT;
} // }
if (ActivityTypeEnum.TYPE_DELIVERY.getCode().equals(activityType)) { // if (ActivityTypeEnum.TYPE_DELIVERY.getCode().equals(activityType)) {
return QueryOrderAccountType.DELIVERY_AMOUNT; // return QueryOrderAccountType.DELIVERY_AMOUNT;
} // }
if (ActivityTypeEnum.TYPE_61.getCode().equals(activityType)) { // if (ActivityTypeEnum.TYPE_61.getCode().equals(activityType)) {
return QueryOrderAccountType.BUYM_SENDN; // return QueryOrderAccountType.BUYM_SENDN;
} // }
//
return null; // return null;
} // }
public boolean isCouponType(Integer type) { // public boolean isCouponType(Integer type) {
return type.equals(ActivityTypeEnum.TYPE_3.getCode()) || type.equals(ActivityTypeEnum.TYPE_31.getCode()) || type.equals(ActivityTypeEnum.TYPE_32.getCode()); // return type.equals(ActivityTypeEnum.TYPE_3.getCode()) || type.equals(ActivityTypeEnum.TYPE_31.getCode()) || type.equals(ActivityTypeEnum.TYPE_32.getCode());
} // }
public SyncStatusDto convent2SyncStatusDtoCreate(AssortmentOpenPlatformWxapp wxApp, UserLoginInfoDto userLoginInfoDto, CreateOrderDto createOrderDto, String oid) { // public SyncStatusDto convent2SyncStatusDtoCreate(AssortmentOpenPlatformWxapp wxApp, UserLoginInfoDto userLoginInfoDto, CreateOrderDto createOrderDto, String oid) {
SyncStatusDto syncStatusDto = new SyncStatusDto(); // SyncStatusDto syncStatusDto = new SyncStatusDto();
syncStatusDto.setSp_mchid(SPMCHID); // syncStatusDto.setSp_mchid(SPMCHID);
syncStatusDto.setSub_mchid(wxApp.getMchId()); // syncStatusDto.setSub_mchid(wxApp.getMchId());
syncStatusDto.setSp_appid(SPWXAPPID); // syncStatusDto.setSp_appid(SPWXAPPID);
syncStatusDto.setSub_appid(userLoginInfoDto.getWxAppid()); // syncStatusDto.setSub_appid(userLoginInfoDto.getWxAppId());
syncStatusDto.setOut_shop_no(createOrderDto.getShopId()); // syncStatusDto.setOut_shop_no(createOrderDto.getShopId());
syncStatusDto.setOpenid(userLoginInfoDto.getOpenId()); // syncStatusDto.setOpenid(userLoginInfoDto.getOpenId());
syncStatusDto.setLogin_token(userLoginInfoDto.getSessionKey()); // syncStatusDto.setLogin_token(userLoginInfoDto.getSessionKey());
syncStatusDto.setOrder_entry(ENTRYPAGE); // syncStatusDto.setOrder_entry(ENTRYPAGE);
syncStatusDto.setUser_amount(createOrderDto.getAmount().intValue()); // syncStatusDto.setUser_amount(createOrderDto.getAmount().intValue());
syncStatusDto.setStatus(WechatSyncStatus.CREATE_DEAL.getCode()); // syncStatusDto.setStatus(WechatSyncStatus.CREATE_DEAL.getCode());
syncStatusDto.setAction_time(Rfc3339Util.dateToRfc3339(new Date())); // syncStatusDto.setAction_time(Rfc3339Util.dateToRfc3339(new Date()));
syncStatusDto.setOut_order_no(oid); // syncStatusDto.setOut_order_no(oid);
List<CreateOrderProductDto> products = createOrderDto.getProducts(); // List<CreateOrderProductDto> products = createOrderDto.getProducts();
List<SyncStatusDto.DishInfo> list = Lists.newArrayList(); // List<SyncStatusDto.DishInfo> list = Lists.newArrayList();
int totalAmount = 0; // int totalAmount = 0;
int discountAmount = 0; // int discountAmount = 0;
for (CreateOrderProductDto productDto : products) { // for (CreateOrderProductDto productDto : products) {
SyncStatusDto.DishInfo dishInfo = new SyncStatusDto.DishInfo(); // SyncStatusDto.DishInfo dishInfo = new SyncStatusDto.DishInfo();
dishInfo.setOut_dish_no(productDto.getProductId()); // dishInfo.setOut_dish_no(productDto.getProductId());
dishInfo.setName(productDto.getProductName()); // dishInfo.setName(productDto.getProductName());
dishInfo.setPrice(productDto.getPrice().intValue()); // dishInfo.setPrice(productDto.getPrice().intValue());
dishInfo.setUnit(WechatUnitType.BY_SHARE.getCode()); // dishInfo.setUnit(WechatUnitType.BY_SHARE.getCode());
dishInfo.setCount(productDto.getNumber().floatValue()); // dishInfo.setCount(productDto.getNumber().floatValue());
list.add(dishInfo); // list.add(dishInfo);
totalAmount += productDto.getPrice().intValue() * productDto.getNumber(); // totalAmount += productDto.getPrice().intValue() * productDto.getNumber();
discountAmount += productDto.getSalePrice().intValue() * productDto.getNumber(); // discountAmount += productDto.getSalePrice().intValue() * productDto.getNumber();
} // }
syncStatusDto.setTotal_amount(totalAmount); // syncStatusDto.setTotal_amount(totalAmount);
syncStatusDto.setDiscount_amount(discountAmount); // syncStatusDto.setDiscount_amount(discountAmount);
syncStatusDto.setDish_list(list); // syncStatusDto.setDish_list(list);
return syncStatusDto; // return syncStatusDto;
} // }
//
public SyncStatusDto convent2SyncStatusDtPay(AssortmentOpenPlatformWxapp wxApp, QueryOrdersResponseDto.DataBean.OrderBean orderBean, String wxappid, String openid, String sessionKey, PaysuccessNoticeMessage message, OrderExtInfoDto orderExtInfoDto) { // public SyncStatusDto convent2SyncStatusDtPay(AssortmentOpenPlatformWxapp wxApp, QueryOrdersResponseDto.DataBean.OrderBean orderBean, String wxappid, String openid, String sessionKey, PaysuccessNoticeMessage message, OrderExtInfoDto orderExtInfoDto) {
SyncStatusDto syncStatusDto = new SyncStatusDto(); // SyncStatusDto syncStatusDto = new SyncStatusDto();
syncStatusDto.setSp_mchid(SPMCHID); // syncStatusDto.setSp_mchid(SPMCHID);
syncStatusDto.setSub_mchid(wxApp.getMchId()); // syncStatusDto.setSub_mchid(wxApp.getMchId());
syncStatusDto.setSp_appid(SPWXAPPID); // syncStatusDto.setSp_appid(SPWXAPPID);
syncStatusDto.setSub_appid(wxappid); // syncStatusDto.setSub_appid(wxappid);
syncStatusDto.setOut_shop_no(orderBean.getShopId()); // syncStatusDto.setOut_shop_no(orderBean.getShopId());
syncStatusDto.setOpenid(openid); // syncStatusDto.setOpenid(openid);
syncStatusDto.setLogin_token(sessionKey); // syncStatusDto.setLogin_token(sessionKey);
syncStatusDto.setOrder_entry(ENTRYPAGE); // syncStatusDto.setOrder_entry(ENTRYPAGE);
syncStatusDto.setUser_amount(orderBean.getAmount().intValue()); // syncStatusDto.setUser_amount(orderBean.getAmount().intValue());
syncStatusDto.setStatus(WechatSyncStatus.PAY_SUCCESS.getCode()); // syncStatusDto.setStatus(WechatSyncStatus.PAY_SUCCESS.getCode());
syncStatusDto.setAction_time(Rfc3339Util.dateToRfc3339(new Date())); // syncStatusDto.setAction_time(Rfc3339Util.dateToRfc3339(new Date()));
syncStatusDto.setPay_time(Rfc3339Util.strToRfc3339(orderExtInfoDto.getPayDate())); // syncStatusDto.setPay_time(Rfc3339Util.strToRfc3339(orderExtInfoDto.getPayDate()));
syncStatusDto.setTransaction_id(message.getPaid_no()); // syncStatusDto.setTransaction_id(message.getPaid_no());
syncStatusDto.setOut_trade_no(message.getOut_trade_no()); // syncStatusDto.setOut_trade_no(message.getOut_trade_no());
syncStatusDto.setOut_order_no(message.getTrans_id()); // syncStatusDto.setOut_order_no(message.getTrans_id());
List<SyncStatusDto.DishInfo> list = Lists.newArrayList(); // List<SyncStatusDto.DishInfo> list = Lists.newArrayList();
int totalAmount = 0; // int totalAmount = 0;
int discountAmount = 0; // int discountAmount = 0;
List<QueryOrdersResponseDto.DataBean.OrderBean.ProductBean> productList = orderBean.getProductList(); // List<QueryOrdersResponseDto.DataBean.OrderBean.ProductBean> productList = orderBean.getProductList();
for (QueryOrdersResponseDto.DataBean.OrderBean.ProductBean productDto : productList) { // for (QueryOrdersResponseDto.DataBean.OrderBean.ProductBean productDto : productList) {
SyncStatusDto.DishInfo dishInfo = new SyncStatusDto.DishInfo(); // SyncStatusDto.DishInfo dishInfo = new SyncStatusDto.DishInfo();
dishInfo.setOut_dish_no(productDto.getProductId()); // dishInfo.setOut_dish_no(productDto.getProductId());
dishInfo.setName(productDto.getProductName()); // dishInfo.setName(productDto.getProductName());
dishInfo.setPrice(productDto.getPrice().intValue()); // dishInfo.setPrice(productDto.getPrice().intValue());
dishInfo.setUnit(WechatUnitType.BY_SHARE.getCode()); // dishInfo.setUnit(WechatUnitType.BY_SHARE.getCode());
dishInfo.setCount(productDto.getNumber()); // dishInfo.setCount(productDto.getNumber());
list.add(dishInfo); // list.add(dishInfo);
totalAmount += productDto.getPrice().intValue() * productDto.getNumber(); // totalAmount += productDto.getPrice().intValue() * productDto.getNumber();
discountAmount += productDto.getSalePrice().intValue() * productDto.getNumber(); // discountAmount += productDto.getSalePrice().intValue() * productDto.getNumber();
} // }
syncStatusDto.setTotal_amount(totalAmount); // syncStatusDto.setTotal_amount(totalAmount);
syncStatusDto.setDiscount_amount(discountAmount); // syncStatusDto.setDiscount_amount(discountAmount);
syncStatusDto.setDish_list(list); // syncStatusDto.setDish_list(list);
return syncStatusDto; // return syncStatusDto;
} // }
//
public String convent2Sign(SyncStatusDto syncStatusDto) { // public String convent2Sign(SyncStatusDto syncStatusDto) {
String authorization = null; // String authorization = null;
try { // try {
SignMessageBuilder signMessageBuilder = new SignMessageBuilder() // SignMessageBuilder signMessageBuilder = new SignMessageBuilder()
.url(new URL("https://api.mch.weixin.qq.com/v3/catering/orders/sync-status")) // .url(new URL("https://api.mch.weixin.qq.com/v3/catering/orders/sync-status"))
.nonceStr(UUID.randomUUID().toString().replace("-", "")) // .nonceStr(UUID.randomUUID().toString().replace("-", ""))
.timestamp(System.currentTimeMillis() / 1000) // .timestamp(System.currentTimeMillis() / 1000)
.httpMethod("POST") // .httpMethod("POST")
.httpBody(gson.toJson(syncStatusDto)); // .httpBody(gson.toJson(syncStatusDto));
//
//
authorization = getAuthorizationString(signMessageBuilder); // authorization = getAuthorizationString(signMessageBuilder);
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
return authorization; // return authorization;
} // }
/** /**
* 获取Authorization串 * 获取Authorization串
......
package cn.freemud.adapter; //package cn.freemud.adapter;
//
import cn.freemud.entities.dto.*; //import cn.freemud.entities.dto.*;
import cn.freemud.entities.vo.AddDeliveryAddressVo; //import cn.freemud.entities.vo.AddDeliveryAddressVo;
import cn.freemud.entities.vo.CreateOrderVo; //import cn.freemud.entities.vo.CreateOrderVo;
import cn.freemud.entities.vo.QueryReceiveAddressResponseVo; //import cn.freemud.entities.vo.QueryReceiveAddressResponseVo;
import cn.freemud.entities.vo.UserLoginVo; //import cn.freemud.entities.vo.UserLoginVo;
import cn.freemud.enums.ReceiveAddressLabelType; //import cn.freemud.enums.ReceiveAddressLabelType;
import cn.freemud.enums.SexType; //import cn.freemud.enums.SexType;
import cn.freemud.manager.OpenPlatformPartnerStoreDeliveryConfigManager; //import cn.freemud.manager.OpenPlatformPartnerStoreDeliveryConfigManager;
import cn.freemud.service.impl.StoreServiceImpl; //import cn.freemud.service.impl.StoreServiceImpl;
import cn.freemud.utils.UnicodeUtil; //import cn.freemud.utils.UnicodeUtil;
import com.alibaba.fastjson.JSONObject; //import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists; //import com.google.common.collect.Lists;
import com.google.common.collect.Maps; //import com.google.common.collect.Maps;
import com.google.gson.Gson; //import com.google.gson.Gson;
import org.apache.commons.collections4.CollectionUtils; //import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils; //import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
//
import java.util.*; //import java.util.*;
import java.util.stream.Collectors; //import java.util.stream.Collectors;
//
@Component //@Component
public class UserAdapter { //public class UserAdapter {
//
public UserLoginInfoDto getUserLoginInfoDto(Map<String, Object> map) { // public UserLoginInfoDto getUserLoginInfoDto(Map<String, Object> map) {
UserLoginInfoDto userLoginInfoDto = new UserLoginInfoDto(); // UserLoginInfoDto userLoginInfoDto = new UserLoginInfoDto();
userLoginInfoDto.setOpenId(String.valueOf(map.get("openid"))); // userLoginInfoDto.setOpenId(String.valueOf(map.get("openid")));
userLoginInfoDto.setWxAppid(String.valueOf(map.get("wxAppid"))); // userLoginInfoDto.setWxAppId(String.valueOf(map.get("wxAppId")));
userLoginInfoDto.setSessionKey(String.valueOf(map.get("session_key"))); // userLoginInfoDto.setSessionKey(String.valueOf(map.get("session_key")));
userLoginInfoDto.setMobile(String.valueOf(map.get("mobile"))); // userLoginInfoDto.setMobile(String.valueOf(map.get("mobile")));
userLoginInfoDto.setAppsecret(String.valueOf(map.get("appsecret"))); // userLoginInfoDto.setAppSecret(String.valueOf(map.get("appsecret")));
userLoginInfoDto.setMemberId(String.valueOf(map.get("memberId"))); // userLoginInfoDto.setMemberId(String.valueOf(map.get("memberId")));
userLoginInfoDto.setPartnerId(String.valueOf(map.get("partnerId"))); // userLoginInfoDto.setPartnerId(String.valueOf(map.get("partnerId")));
userLoginInfoDto.setUnionId(String.valueOf(map.get("unionId"))); // userLoginInfoDto.setUnionId(String.valueOf(map.get("unionId")));
userLoginInfoDto.setNewMemeber(Boolean.valueOf(map.get("newMember").toString())); // userLoginInfoDto.setNewMember(Boolean.valueOf(map.get("newMember").toString()));
userLoginInfoDto.setNickName(String.valueOf(map.get("nickName"))); // userLoginInfoDto.setNickName(String.valueOf(map.get("nickName")));
return userLoginInfoDto; // return userLoginInfoDto;
} // }
} //}
package cn.freemud.entities.dto; //package cn.freemud.entities.dto;
//
import lombok.Data; //import lombok.Data;
//
@Data //@Data
public class UserLoginInfoDto { //public class UserLoginInfoDto {
//
private String openId; //// private String openId;
////
private String wxAppid; //// private String wxAppid;
////
private String sessionKey; //// private String sessionKey;
////
private String mobile; //// private String mobile;
////
private String appsecret; //// private String appsecret;
////
private String memberId; //// private String memberId;
////
private String partnerId; //// private String partnerId;
////
private boolean newMemeber; //// private boolean newMemeber;
////
private String unionId; //// private String unionId;
////
private String nickName; //// private String nickName;
} //
//
// private String openId;
// private String unionId;
// private String wxAppId;
// private String sessionKey;
// private String mobile;
// private String appSecret;
// private String memberId;
// private String partnerId;
// private Boolean newMember;
// private String devBrand;
// private String devModel;
// private String channel;
// private String nickName;
// private String photoUrl;
// private String sessionId;
// private String tableNumber;
// private String iappId;
// private String storeId;
// private String userId;
// private String accessToken;
// private String alipayUserId;
// private String alipayAppId;
//}
package cn.freemud.entities.dto.user; //package cn.freemud.entities.dto.user;
//
import lombok.Builder; //import lombok.Builder;
import lombok.Data; //import lombok.Data;
//
@Data //@Data
@Builder //@Builder
public class UserInfoDto { //public class UserInfoDto {
//
private String openId; // private String openId;
//
private String unionId; // private String unionId;
//
private String wxAppid; // private String wxAppid;
//
private String sessionKey; // private String sessionKey;
//
private String mobile; // private String mobile;
//
private String appsecret; // private String appsecret;
//
private String memberId; // private String memberId;
//
private String partnerId; // private String partnerId;
//
private Boolean newMemeber; // private Boolean newMemeber;
//
private String devBrand; // private String devBrand;
//
private String devModel; // private String devModel;
//
private String channel; // private String channel;
//
//
} //}
package cn.freemud.service; //package cn.freemud.service;
//
import cn.freemud.entities.dto.UserLoginInfoDto; //import cn.freemud.entities.dto.UserLoginInfoDto;
//
import java.util.Map; //import java.util.Map;
//
/** ///**
* 用户服务 // * 用户服务
* // *
* @author liming.guo // * @author liming.guo
* @date 2018/05/08 // * @date 2018/05/08
*/ // */
public interface UserService { //public interface UserService {
//
Map<String, Object> getUserInfoMapBySessionId(String sessionId); // Map<String, Object> getUserInfoMapBySessionId(String sessionId);
//
/** // /**
* 获取缓存用户信息 // * 获取缓存用户信息
* // *
* @param sessionId // * @param sessionId
* @return // * @return
*/ // */
UserLoginInfoDto getUserLoginInfoBySessionId(String sessionId); // UserLoginInfoDto getUserLoginInfoBySessionId(String sessionId);
//
} //}
...@@ -5,20 +5,16 @@ import cn.freemud.base.util.DateUtil; ...@@ -5,20 +5,16 @@ import cn.freemud.base.util.DateUtil;
import cn.freemud.constant.RedisKeyConstant; import cn.freemud.constant.RedisKeyConstant;
import cn.freemud.entities.db.OpenPlatformIappWxappConfig; import cn.freemud.entities.db.OpenPlatformIappWxappConfig;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
import cn.freemud.entities.vo.ShoppingCartSkuAddRequestVo;
import cn.freemud.enums.BuriedPointEnum;
import cn.freemud.enums.GuessLikeStatus; import cn.freemud.enums.GuessLikeStatus;
import cn.freemud.manager.OpenPlatformIappWxappConfigManager; import cn.freemud.manager.OpenPlatformIappWxappConfigManager;
import cn.freemud.redis.RedisCache; import cn.freemud.redis.RedisCache;
import cn.freemud.service.BuriedPointService; import cn.freemud.service.BuriedPointService;
import cn.freemud.service.UserService;
import cn.freemud.service.thirdparty.SyncTxProductClient; import cn.freemud.service.thirdparty.SyncTxProductClient;
import cn.freemud.utils.LogUtil; import cn.freemud.utils.LogUtil;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformWxapp; import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformWxapp;
import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformWxappManager; import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformWxappManager;
import com.google.gson.Gson; import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -33,7 +29,6 @@ import java.util.ArrayList; ...@@ -33,7 +29,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* All rights Reserved, Designed By www.freemud.cn * All rights Reserved, Designed By www.freemud.cn
......
...@@ -19,12 +19,10 @@ import cn.freemud.entities.db.OpenPlatformIappWxappConfig; ...@@ -19,12 +19,10 @@ import cn.freemud.entities.db.OpenPlatformIappWxappConfig;
import cn.freemud.entities.db.OpenPlatformPartnerStoreDeliveryConfig; import cn.freemud.entities.db.OpenPlatformPartnerStoreDeliveryConfig;
import cn.freemud.entities.db.StoreTableNumber; import cn.freemud.entities.db.StoreTableNumber;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.order.CreateOrderDto;
import cn.freemud.entities.dto.shoppingCart.GetShoppingCartGoodsApportionDto; import cn.freemud.entities.dto.shoppingCart.GetShoppingCartGoodsApportionDto;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.CreateOrderVo; import cn.freemud.entities.vo.CreateOrderVo;
import cn.freemud.entities.vo.GetMemberCouponRequestVo; import cn.freemud.entities.vo.GetMemberCouponRequestVo;
import cn.freemud.entities.vo.GetProductsVo;
import cn.freemud.entities.vo.ShoppingCartInfoRequestVo; import cn.freemud.entities.vo.ShoppingCartInfoRequestVo;
import cn.freemud.enums.CouponFlag; import cn.freemud.enums.CouponFlag;
import cn.freemud.enums.CreateOrderType; import cn.freemud.enums.CreateOrderType;
...@@ -38,6 +36,8 @@ import cn.freemud.service.thirdparty.ShoppingCartClient; ...@@ -38,6 +36,8 @@ import cn.freemud.service.thirdparty.ShoppingCartClient;
import cn.freemud.service.thirdparty.StockClient; import cn.freemud.service.thirdparty.StockClient;
import cn.freemud.utils.LogUtil; import cn.freemud.utils.LogUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo;
import com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager;
import com.freemud.application.sdk.api.base.BaseResponse; import com.freemud.application.sdk.api.base.BaseResponse;
import com.freemud.application.sdk.api.log.LogThreadLocal; import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest; import com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest;
...@@ -73,8 +73,10 @@ public class CheckOrder { ...@@ -73,8 +73,10 @@ public class CheckOrder {
@Autowired @Autowired
private OpenPlatformPartnerStoreDeliveryConfigManager deliveryConfigManager; private OpenPlatformPartnerStoreDeliveryConfigManager deliveryConfigManager;
// 缓存取用户数据用 // 缓存取用户数据用
// @Autowired
// private UserServiceImpl userService;
@Autowired @Autowired
private UserServiceImpl userService; private AssortmentCustomerInfoManager customerInfoManager;
//门店SDK //门店SDK
@Autowired @Autowired
private StoreCenterService storeCenterService; private StoreCenterService storeCenterService;
...@@ -100,9 +102,13 @@ public class CheckOrder { ...@@ -100,9 +102,13 @@ public class CheckOrder {
/** /**
* 下单会员相关校验 * 下单会员相关校验
*/ */
public UserLoginInfoDto checkOrderByMember(CreateOrderVo createOrderVo, String trackingNo) { public AssortmentCustomerInfoVo checkOrderByMember(CreateOrderVo createOrderVo, String trackingNo) {
// 通过sessionId查询缓存中会员id // 通过sessionId查询缓存中会员id
UserLoginInfoDto userLoginInfoDto = userService.getUserLoginInfoBySessionId(createOrderVo.getSessionId()); String sessionId = createOrderVo.getSessionId();
AssortmentCustomerInfoVo userLoginInfoDto = customerInfoManager.getCustomerInfoByObject(sessionId);
if (userLoginInfoDto == null || StringUtils.isEmpty(userLoginInfoDto.getMemberId())) {
throw new ServiceException(ResponseResult.NOT_LOGIN);
}
//校验会员svc卡信息 //校验会员svc卡信息
checkCardCode(createOrderVo.getPartnerId(),userLoginInfoDto.getMemberId(),createOrderVo.getCardCode(),trackingNo); checkCardCode(createOrderVo.getPartnerId(),userLoginInfoDto.getMemberId(),createOrderVo.getCardCode(),trackingNo);
...@@ -179,7 +185,7 @@ public class CheckOrder { ...@@ -179,7 +185,7 @@ public class CheckOrder {
/** /**
* 下单订单类型校验 * 下单订单类型校验
*/ */
public Integer checkOrderByOrderType(CreateOrderVo createOrderVo, UserLoginInfoDto userLoginInfoDto, public Integer checkOrderByOrderType(CreateOrderVo createOrderVo, AssortmentCustomerInfoVo userLoginInfoDto,
StoreResponse.BizVO storeResponseDto,Long totalAmount, String trackingNo) { StoreResponse.BizVO storeResponseDto,Long totalAmount, String trackingNo) {
Integer pushOrderTime = 0; Integer pushOrderTime = 0;
//TODO 设置预约时间 //TODO 设置预约时间
...@@ -191,7 +197,7 @@ public class CheckOrder { ...@@ -191,7 +197,7 @@ public class CheckOrder {
.append(" ").append(createOrderVo.getTakeMealTime()).append(":00"); .append(" ").append(createOrderVo.getTakeMealTime()).append(":00");
takeMealDateTime = DateUtil.convert2Date(takeMealTime.toString(), "yyyy-MM-dd HH:mm:ss"); takeMealDateTime = DateUtil.convert2Date(takeMealTime.toString(), "yyyy-MM-dd HH:mm:ss");
} }
String wxAppId = userLoginInfoDto.getWxAppid(); String wxAppId = userLoginInfoDto.getWxAppId();
// 校验小程序是否支持到店或者外卖 // 校验小程序是否支持到店或者外卖
OpenPlatformIappWxappConfig config = openPlatformIappWxappConfigManager.selectIappWxappConfigByWxAppId(wxAppId); OpenPlatformIappWxappConfig config = openPlatformIappWxappConfigManager.selectIappWxappConfigByWxAppId(wxAppId);
// 自提校验 // 自提校验
...@@ -223,7 +229,7 @@ public class CheckOrder { ...@@ -223,7 +229,7 @@ public class CheckOrder {
throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY); throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY);
} }
//获取门店配送信息 //获取门店配送信息
StoreDeliveryInfoDto storeDeliveryInfoDto = getStoreDeliveryInfo(storeResponseDto, config, userLoginInfoDto.getWxAppid()); StoreDeliveryInfoDto storeDeliveryInfoDto = getStoreDeliveryInfo(storeResponseDto, config, wxAppId);
//订单金额小于起送费提示 //订单金额小于起送费提示
if (storeDeliveryInfoDto.getDeliveryLimitAmount() > totalAmount) { if (storeDeliveryInfoDto.getDeliveryLimitAmount() > totalAmount) {
throw new ServiceException(ResponseResult.STORE_DISCONTENT_DELIVERY_FEE); throw new ServiceException(ResponseResult.STORE_DISCONTENT_DELIVERY_FEE);
......
...@@ -2,28 +2,22 @@ package cn.freemud.service.impl; ...@@ -2,28 +2,22 @@ package cn.freemud.service.impl;
import cn.freemud.adapter.MessageNoticeAdapter; import cn.freemud.adapter.MessageNoticeAdapter;
import cn.freemud.adapter.OrderAdapter; import cn.freemud.adapter.OrderAdapter;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.base.log.LogTreadLocal; import cn.freemud.base.log.LogTreadLocal;
import cn.freemud.base.util.DateUtil; import cn.freemud.base.util.DateUtil;
import cn.freemud.constant.ResponseCodeConstant; import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.OrderExtInfoDto; import cn.freemud.entities.dto.OrderExtInfoDto;
import cn.freemud.entities.dto.ShoppingCartBaseResponse; import cn.freemud.entities.dto.ShoppingCartBaseResponse;
import cn.freemud.entities.dto.StoreBaseResponseDto;
import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.dto.shoppingCart.NewShoppingCartClearDto; import cn.freemud.entities.dto.shoppingCart.NewShoppingCartClearDto;
import cn.freemud.entities.vo.CreateOrderResponseVo; import cn.freemud.entities.vo.CreateOrderResponseVo;
import cn.freemud.entities.vo.PaysuccessNoticeMessage; import cn.freemud.entities.vo.PaysuccessNoticeMessage;
import cn.freemud.enums.PayStatus; import cn.freemud.enums.PayStatus;
import cn.freemud.enums.RedisCacheEnum; import cn.freemud.enums.RedisCacheEnum;
import cn.freemud.enums.ResponseResult; import cn.freemud.enums.ResponseResult;
import cn.freemud.enums.TransTypeEnum;
import cn.freemud.interceptor.ServiceException; import cn.freemud.interceptor.ServiceException;
import cn.freemud.redis.RedisCache; import cn.freemud.redis.RedisCache;
import cn.freemud.service.thirdparty.ShoppingCartClient; import cn.freemud.service.thirdparty.ShoppingCartClient;
import cn.freemud.service.thirdparty.StoreClient;
import cn.freemud.utils.DateTimeUtil; import cn.freemud.utils.DateTimeUtil;
import cn.freemud.utils.LogUtil; import cn.freemud.utils.LogUtil;
import cn.freemud.utils.ResponseUtil;
import cn.freemud.utils.ValidationCode; import cn.freemud.utils.ValidationCode;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -34,12 +28,9 @@ import com.freemud.api.assortment.datamanager.meal.MealCacheManager; ...@@ -34,12 +28,9 @@ import com.freemud.api.assortment.datamanager.meal.MealCacheManager;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare; import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import com.freemud.application.sdk.api.log.ApiLog; import com.freemud.application.sdk.api.log.ApiLog;
import com.freemud.application.sdk.api.log.LogThreadLocal; import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.ordercenter.enums.AfterSalesType;
import com.freemud.application.sdk.api.ordercenter.enums.OrderClientType; import com.freemud.application.sdk.api.ordercenter.enums.OrderClientType;
import com.freemud.application.sdk.api.ordercenter.enums.ProductTypeEnum; import com.freemud.application.sdk.api.ordercenter.enums.ProductTypeEnum;
import com.freemud.application.sdk.api.storecenter.request.ChangeTableActiveFlagRequest;
import com.freemud.application.sdk.api.storecenter.request.ChangeTableOrderStateRequest; import com.freemud.application.sdk.api.storecenter.request.ChangeTableOrderStateRequest;
import com.freemud.application.sdk.api.storecenter.response.StoreBaseResponse;
import com.freemud.application.sdk.api.storecenter.service.StoreCenterService; import com.freemud.application.sdk.api.storecenter.service.StoreCenterService;
import com.freemud.application.sdk.api.structure.request.PushMessageNoticeDto; import com.freemud.application.sdk.api.structure.request.PushMessageNoticeDto;
import com.freemud.application.sdk.api.structure.service.MessageCenterClient; import com.freemud.application.sdk.api.structure.service.MessageCenterClient;
...@@ -54,22 +45,17 @@ import com.freemud.sdk.api.assortment.payment.request.UnifiedOrderRequest; ...@@ -54,22 +45,17 @@ import com.freemud.sdk.api.assortment.payment.request.UnifiedOrderRequest;
import com.freemud.sdk.api.assortment.payment.response.UnifiedOrderResponse; import com.freemud.sdk.api.assortment.payment.response.UnifiedOrderResponse;
import com.freemud.sdk.api.assortment.payment.service.StandardPaymentService; import com.freemud.sdk.api.assortment.payment.service.StandardPaymentService;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.sun.org.apache.regexp.internal.RE;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/** /**
* All rights Reserved, Designed By www.freemud.cn * All rights Reserved, Designed By www.freemud.cn
......
...@@ -260,7 +260,7 @@ public class OrderServiceImpl implements Orderservice { ...@@ -260,7 +260,7 @@ public class OrderServiceImpl implements Orderservice {
public BaseResponse createOrderNew(CreateOrderVo createOrderVo) { public BaseResponse createOrderNew(CreateOrderVo createOrderVo) {
String trackingNo = LogThreadLocal.getTrackingNo(); String trackingNo = LogThreadLocal.getTrackingNo();
// 查询用户信息、校验svc卡,余额购物车校验 // 查询用户信息、校验svc卡,余额购物车校验
UserLoginInfoDto userLoginInfoDto = checkOrder.checkOrderByMember(createOrderVo, trackingNo); AssortmentCustomerInfoVo userLoginInfoDto = checkOrder.checkOrderByMember(createOrderVo, trackingNo);
// 查询门店信息 营业时间、营业状态,服务器当前时间在营业时间内 点餐桌号 // 查询门店信息 营业时间、营业状态,服务器当前时间在营业时间内 点餐桌号
StoreResponse.BizVO storeResponseDto = checkOrder.checkOrderByStore(createOrderVo, trackingNo); StoreResponse.BizVO storeResponseDto = checkOrder.checkOrderByStore(createOrderVo, trackingNo);
// 查询购物车(内部校验券点餐方式,券是否可用) 校验当前订单类型的下单参数 // 查询购物车(内部校验券点餐方式,券是否可用) 校验当前订单类型的下单参数
...@@ -282,7 +282,7 @@ public class OrderServiceImpl implements Orderservice { ...@@ -282,7 +282,7 @@ public class OrderServiceImpl implements Orderservice {
public BaseResponse scanFaceCreateOrder(CreateOrderVo createOrderVo) { public BaseResponse scanFaceCreateOrder(CreateOrderVo createOrderVo) {
String trackingNo = LogThreadLocal.getTrackingNo(); String trackingNo = LogThreadLocal.getTrackingNo();
// 查询用户信息、校验svc卡,余额购物车校验 // 查询用户信息、校验svc卡,余额购物车校验
UserLoginInfoDto userLoginInfoDto = checkOrder.checkOrderByMember(createOrderVo, trackingNo); AssortmentCustomerInfoVo userLoginInfoDto = checkOrder.checkOrderByMember(createOrderVo, trackingNo);
// 查询门店信息 营业时间、营业状态,服务器当前时间在营业时间内 点餐桌号 // 查询门店信息 营业时间、营业状态,服务器当前时间在营业时间内 点餐桌号
StoreResponse.BizVO storeResponseDto = checkOrder.checkOrderByStore(createOrderVo, trackingNo); StoreResponse.BizVO storeResponseDto = checkOrder.checkOrderByStore(createOrderVo, trackingNo);
// 查询购物车(内部校验券点餐方式,券是否可用) 校验当前订单类型的下单参数 // 查询购物车(内部校验券点餐方式,券是否可用) 校验当前订单类型的下单参数
...@@ -1707,7 +1707,8 @@ public class OrderServiceImpl implements Orderservice { ...@@ -1707,7 +1707,8 @@ public class OrderServiceImpl implements Orderservice {
* *
* @return * @return
*/ */
private BaseResponse sdkCreateOrder(CreateOrderVo createOrderVo, StoreResponse.BizVO storeResponseDto, ShoppingCartGoodsDto shoppingCartGoodsDto, UserLoginInfoDto userLoginInfoDto, OrderExtInfoDTO orderExtInfoDTO) { private BaseResponse sdkCreateOrder(CreateOrderVo createOrderVo, StoreResponse.BizVO storeResponseDto, ShoppingCartGoodsDto shoppingCartGoodsDto,
AssortmentCustomerInfoVo userLoginInfoDto, OrderExtInfoDTO orderExtInfoDTO) {
OrderExtendedReq orderExtendedReq = orderAdapter.saveStoreInfo(storeResponseDto); OrderExtendedReq orderExtendedReq = orderAdapter.saveStoreInfo(storeResponseDto);
String orderWarnTime = storeResponseDto.getOrderWarnTime(); String orderWarnTime = storeResponseDto.getOrderWarnTime();
//创建普通订单 //创建普通订单
...@@ -1916,8 +1917,8 @@ public class OrderServiceImpl implements Orderservice { ...@@ -1916,8 +1917,8 @@ public class OrderServiceImpl implements Orderservice {
return orderPayResponse; return orderPayResponse;
} }
private PaymentRequest orderBodyConvertToPaymentBody(UserLoginInfoDto userLoginInfoDto, String partnerId) { private PaymentRequest orderBodyConvertToPaymentBody(AssortmentCustomerInfoVo userLoginInfoDto, String partnerId) {
String wxAppId = userLoginInfoDto.getWxAppid(); String wxAppId = userLoginInfoDto.getWxAppId();
//设置支付信息 //设置支付信息
PaymentRequest paymentRequest = new PaymentRequest(); PaymentRequest paymentRequest = new PaymentRequest();
paymentRequest.setOpenId(userLoginInfoDto.getOpenId()); paymentRequest.setOpenId(userLoginInfoDto.getOpenId());
...@@ -1928,7 +1929,7 @@ public class OrderServiceImpl implements Orderservice { ...@@ -1928,7 +1929,7 @@ public class OrderServiceImpl implements Orderservice {
return paymentRequest; return paymentRequest;
} }
public OrderExtInfoDTO getExtInfo(UserLoginInfoDto userLoginInfoDto, StoreResponse.BizVO storeResponseDto, public OrderExtInfoDTO getExtInfo(AssortmentCustomerInfoVo userLoginInfoDto, StoreResponse.BizVO storeResponseDto,
Integer pushOrderTime, CreateOrderVo createOrderVo) { Integer pushOrderTime, CreateOrderVo createOrderVo) {
Integer serviceTime = storeResponseDto.getServiceTime(); Integer serviceTime = storeResponseDto.getServiceTime();
...@@ -1950,7 +1951,7 @@ public class OrderServiceImpl implements Orderservice { ...@@ -1950,7 +1951,7 @@ public class OrderServiceImpl implements Orderservice {
orderExtInfoDto.setDeliveryHoursDayStart(deliveryHoursDayStart); orderExtInfoDto.setDeliveryHoursDayStart(deliveryHoursDayStart);
orderExtInfoDto.setDeliveryHoursDayEnd(deliveryHoursDayEnd); orderExtInfoDto.setDeliveryHoursDayEnd(deliveryHoursDayEnd);
orderExtInfoDto.setOpenid(userLoginInfoDto.getOpenId()); orderExtInfoDto.setOpenid(userLoginInfoDto.getOpenId());
orderExtInfoDto.setAppid(userLoginInfoDto.getWxAppid()); orderExtInfoDto.setAppid(userLoginInfoDto.getWxAppId());
orderExtInfoDto.setSessionId(sessionId); orderExtInfoDto.setSessionId(sessionId);
if (Objects.equals(serviceTime, null)) { if (Objects.equals(serviceTime, null)) {
serviceTime = 50; serviceTime = 50;
...@@ -2153,7 +2154,8 @@ public class OrderServiceImpl implements Orderservice { ...@@ -2153,7 +2154,8 @@ public class OrderServiceImpl implements Orderservice {
/** /**
* 下单支付 * 下单支付
*/ */
private BaseResponse createOrderAndPay(CreateOrderVo createOrderVo, StoreResponse.BizVO storeResponseDto, ShoppingCartGoodsDto shoppingCartGoodsDto, UserLoginInfoDto userLoginInfoDto, OrderExtInfoDTO orderExtInfoDTO) { private BaseResponse createOrderAndPay(CreateOrderVo createOrderVo, StoreResponse.BizVO storeResponseDto, ShoppingCartGoodsDto shoppingCartGoodsDto,
AssortmentCustomerInfoVo userLoginInfoDto, OrderExtInfoDTO orderExtInfoDTO) {
//创建订单--包括下单购买会员卡创建父子订单 //创建订单--包括下单购买会员卡创建父子订单
CreateOrderOperateDto operateDto = createOrder(createOrderVo, storeResponseDto, shoppingCartGoodsDto); CreateOrderOperateDto operateDto = createOrder(createOrderVo, storeResponseDto, shoppingCartGoodsDto);
long totalAmount = operateDto.getTotalAmount(); long totalAmount = operateDto.getTotalAmount();
...@@ -2279,7 +2281,7 @@ public class OrderServiceImpl implements Orderservice { ...@@ -2279,7 +2281,7 @@ public class OrderServiceImpl implements Orderservice {
* 支付 * 支付
* 包含唤起微信支付、储值卡支付直接支付、扫脸支付、商品券无需支付 * 包含唤起微信支付、储值卡支付直接支付、扫脸支付、商品券无需支付
*/ */
private OrderPayResponse pay(UserLoginInfoDto userLoginInfoDto,CreateOrderVo createOrderVo,long totalAmount,int cardAmount, private OrderPayResponse pay(AssortmentCustomerInfoVo userLoginInfoDto,CreateOrderVo createOrderVo,long totalAmount,int cardAmount,
QueryOrdersResponse.DataBean.OrderBean fatherBeanListOne){ QueryOrdersResponse.DataBean.OrderBean fatherBeanListOne){
//<!---创建订单公共方法执行逻辑---> //<!---创建订单公共方法执行逻辑--->
OrderPayResponse orderPayResponse = null; OrderPayResponse orderPayResponse = null;
......
package cn.freemud.service.impl; //package cn.freemud.service.impl;
//
import cn.freemud.adapter.BigDataAdapter; //import cn.freemud.adapter.UserAdapter;
import cn.freemud.adapter.MemberAdapter; //import cn.freemud.constant.RedisKeyConstant;
import cn.freemud.adapter.MessageNoticeAdapter; //import cn.freemud.constant.UserInfoKeyConstant;
import cn.freemud.adapter.UserAdapter; //import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.base.constant.Version; //import cn.freemud.enums.ResponseResult;
import cn.freemud.base.entity.BaseResponse; //import cn.freemud.interceptor.ServiceException;
import cn.freemud.base.util.MD5Util; //import cn.freemud.redis.RedisCache;
import cn.freemud.constant.ApplicationConstant; //import cn.freemud.service.UserService;
import cn.freemud.constant.RedisKeyConstant; //import com.google.gson.Gson;
import cn.freemud.constant.ResponseCodeConstant; //import lombok.extern.slf4j.Slf4j;
import cn.freemud.constant.UserInfoKeyConstant; //import org.springframework.beans.factory.annotation.Autowired;
import cn.freemud.entities.db.Partner; //import org.springframework.stereotype.Service;
import cn.freemud.entities.dto.*; //
import cn.freemud.entities.dto.user.UserInfoDto; //import java.util.Map;
import cn.freemud.entities.vo.*; //
import cn.freemud.enums.*; ///**
import cn.freemud.interceptor.ServiceException; // * @author liming.guo
import cn.freemud.manager.OpenPlatformWxappPluginBindManager; // * @date 2018/05/11
import cn.freemud.manager.PartnerManager; // */
import cn.freemud.redis.RedisCache; //@Service
import cn.freemud.service.UserService; //@Slf4j
import cn.freemud.service.thirdparty.*; //public class UserServiceImpl implements UserService {
import cn.freemud.utils.*; // private static Gson gson = new Gson();
import com.alibaba.fastjson.JSON; // @Autowired
import com.alibaba.fastjson.JSONObject; // private UserAdapter userAdapter;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerMerchant; // @Autowired
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformWxapp; // private RedisCache redisCache;
import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformPartnerMerchantManager; //
import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformWxappManager; // /**
import com.google.common.collect.Maps; // * 校验用户是否登录
import com.google.gson.Gson; // */
import lombok.extern.slf4j.Slf4j; // public void checkUserLogin(String sessionId) {
import org.apache.commons.collections4.CollectionUtils; // Map<String, Object> userInfoMap = this.getUserInfoMapBySessionId(sessionId);
import org.apache.commons.lang.StringUtils; // if (userInfoMap == null || userInfoMap.size() <= 0 || userInfoMap.get(UserInfoKeyConstant.MEMBER_ID) == null) {
import org.bouncycastle.jce.provider.BouncyCastleProvider; // throw new ServiceException(ResponseResult.NOT_LOGIN);
import org.jasypt.contrib.org.apache.commons.codec_1_3.binary.Base64; // }
import org.springframework.beans.factory.annotation.Autowired; // }
import org.springframework.beans.factory.annotation.Value; // /**
import org.springframework.stereotype.Service; // * 校验用户是否登录
// */
import javax.crypto.BadPaddingException; // public boolean checkUserLoginFlag(String sessionId) {
import javax.crypto.Cipher; // Map<String, Object> userInfoMap = this.getUserInfoMapBySessionId(sessionId);
import javax.crypto.spec.IvParameterSpec; // log.info("submit userInfoMap:{}", gson.toJson(userInfoMap));
import javax.crypto.spec.SecretKeySpec; // if (userInfoMap == null || userInfoMap.size() <= 0 || userInfoMap.get(UserInfoKeyConstant.MEMBER_ID) == null) {
import java.net.URLEncoder; // return false;
import java.security.Security; // }
import java.security.spec.AlgorithmParameterSpec; // return true;
import java.util.*; // }
import java.util.concurrent.TimeUnit; //
import java.util.stream.Collectors; // /**
// * 获取缓存用户信息
/** // */
* @author liming.guo // @Override
* @date 2018/05/11 // public Map<String, Object> getUserInfoMapBySessionId(String sessionId) {
*/ // String redisKey = RedisKeyConstant.SAAS_USER_INFO_SESSIONID_KEY_PREFIX + sessionId;
@Service // Map<String, Object> map;
@Slf4j // try {
public class UserServiceImpl implements UserService { // map = redisCache.getValue(redisKey);
private static Gson gson = new Gson(); // }catch (Exception e){
@Autowired // map = redisCache.getValue(redisKey);
private UserAdapter userAdapter; // }
@Autowired // return map;
private RedisCache redisCache; // }
//
/** // /**
* 校验用户是否登录 // * 获取缓存用户信息
*/ // *
public void checkUserLogin(String sessionId) { // * @param sessionId
Map<String, Object> userInfoMap = this.getUserInfoMapBySessionId(sessionId); // * @return
if (userInfoMap == null || userInfoMap.size() <= 0 || userInfoMap.get(UserInfoKeyConstant.MEMBER_ID) == null) { // */
throw new ServiceException(ResponseResult.NOT_LOGIN); // @Override
} // public UserLoginInfoDto getUserLoginInfoBySessionId(String sessionId) {
} // checkUserLogin(sessionId);
/** //
* 校验用户是否登录 // String redisKey = RedisKeyConstant.SAAS_USER_INFO_SESSIONID_KEY_PREFIX + sessionId;
*/ // Map<String, Object> map = redisCache.getValue(redisKey);
public boolean checkUserLoginFlag(String sessionId) { // return userAdapter.getUserLoginInfoDto(map);
Map<String, Object> userInfoMap = this.getUserInfoMapBySessionId(sessionId); // }
log.info("submit userInfoMap:{}", gson.toJson(userInfoMap)); //}
if (userInfoMap == null || userInfoMap.size() <= 0 || userInfoMap.get(UserInfoKeyConstant.MEMBER_ID) == null) {
return false;
}
return true;
}
/**
* 获取缓存用户信息
*/
@Override
public Map<String, Object> getUserInfoMapBySessionId(String sessionId) {
String redisKey = RedisKeyConstant.SAAS_USER_INFO_SESSIONID_KEY_PREFIX + sessionId;
Map<String, Object> map;
try {
map = redisCache.getValue(redisKey);
}catch (Exception e){
map = redisCache.getValue(redisKey);
}
return map;
}
/**
* 获取缓存用户信息
*
* @param sessionId
* @return
*/
@Override
public UserLoginInfoDto getUserLoginInfoBySessionId(String sessionId) {
checkUserLogin(sessionId);
String redisKey = RedisKeyConstant.SAAS_USER_INFO_SESSIONID_KEY_PREFIX + sessionId;
Map<String, Object> map = redisCache.getValue(redisKey);
return userAdapter.getUserLoginInfoDto(map);
}
}
...@@ -3,18 +3,18 @@ package cn.freemud.service.process.WechatPush; ...@@ -3,18 +3,18 @@ package cn.freemud.service.process.WechatPush;
import cn.freemud.amp.body.OrderBody; import cn.freemud.amp.body.OrderBody;
import cn.freemud.entities.dto.QueryOrdersResponseDto; import cn.freemud.entities.dto.QueryOrdersResponseDto;
import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.vo.WxappPluginVo; import cn.freemud.entities.vo.WxappPluginVo;
import cn.freemud.enums.PluginAuditStatusEnum; import cn.freemud.enums.PluginAuditStatusEnum;
import cn.freemud.enums.YesOrNoEnum; import cn.freemud.enums.YesOrNoEnum;
import cn.freemud.manager.OpenPlatformWxappPluginBindManager; import cn.freemud.manager.OpenPlatformWxappPluginBindManager;
import cn.freemud.service.OrderDistributeMQService; import cn.freemud.service.OrderDistributeMQService;
import cn.freemud.service.impl.UserServiceImpl;
import cn.freemud.utils.LogUtil; import cn.freemud.utils.LogUtil;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerConfig; import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerConfig;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformWxapp; import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformWxapp;
import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo;
import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformPartnerConfigManager; import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformPartnerConfigManager;
import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformWxappManager; import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformWxappManager;
import com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager;
import com.freemud.sdk.api.assortment.order.enums.OrderSdkType; import com.freemud.sdk.api.assortment.order.enums.OrderSdkType;
import com.freemud.sdk.api.assortment.order.request.order.BaseQueryOrderRequest; import com.freemud.sdk.api.assortment.order.request.order.BaseQueryOrderRequest;
import com.freemud.sdk.api.assortment.order.response.order.QueryOrderByIdResponse; import com.freemud.sdk.api.assortment.order.response.order.QueryOrderByIdResponse;
...@@ -66,8 +66,10 @@ public class WechatPushProcessor { ...@@ -66,8 +66,10 @@ public class WechatPushProcessor {
@Autowired @Autowired
private AssortmentOpenPlatformWxappManager openPlatformWxappManager; private AssortmentOpenPlatformWxappManager openPlatformWxappManager;
// @Autowired
// private UserServiceImpl userService;
@Autowired @Autowired
private UserServiceImpl userService; private AssortmentCustomerInfoManager customerInfoManager;
/** /**
* 订单创建上送微信 * 订单创建上送微信
...@@ -76,7 +78,7 @@ public class WechatPushProcessor { ...@@ -76,7 +78,7 @@ public class WechatPushProcessor {
* @param oId 订单ID * @param oId 订单ID
* @param companyId 商户号 * @param companyId 商户号
*/ */
public boolean statusOrderCreate(UserLoginInfoDto userLoginInfoDto, String oId, String companyId) { public boolean statusOrderCreate(AssortmentCustomerInfoVo userLoginInfoDto, String oId, String companyId) {
DisRequest disRequest = null; DisRequest disRequest = null;
try { try {
// 判断当前小程序是否开通推荐优惠插件并启用 // 判断当前小程序是否开通推荐优惠插件并启用
...@@ -93,7 +95,7 @@ public class WechatPushProcessor { ...@@ -93,7 +95,7 @@ public class WechatPushProcessor {
} }
QueryOrdersResponse.DataBean.OrderBean orderBean = queryOrderByIdResponse.getData(); QueryOrdersResponse.DataBean.OrderBean orderBean = queryOrderByIdResponse.getData();
// 获取当前商户微信支付mchId // 获取当前商户微信支付mchId
AssortmentOpenPlatformWxapp wxApp = openPlatformWxappManager.findByPartnerIdAndWxappId(userLoginInfoDto.getPartnerId(), userLoginInfoDto.getWxAppid()); AssortmentOpenPlatformWxapp wxApp = openPlatformWxappManager.findByPartnerIdAndWxappId(userLoginInfoDto.getPartnerId(), userLoginInfoDto.getWxAppId());
if (wxApp == null || wxApp.getMchId() == null) { if (wxApp == null || wxApp.getMchId() == null) {
LogUtil.error("syncStatusOrderCreate 订单上送信息 未查询到商户号", gson.toJson(wxApp), ""); LogUtil.error("syncStatusOrderCreate 订单上送信息 未查询到商户号", gson.toJson(wxApp), "");
return false; return false;
...@@ -129,7 +131,7 @@ public class WechatPushProcessor { ...@@ -129,7 +131,7 @@ public class WechatPushProcessor {
return; return;
} }
try { try {
UserLoginInfoDto userLoginInfoDto = userService.getUserLoginInfoBySessionId(sessionId); AssortmentCustomerInfoVo userLoginInfoDto = customerInfoManager.getCustomerInfoByObject(sessionId);
if (null == userLoginInfoDto) { if (null == userLoginInfoDto) {
LogUtil.error("syncStatusOrderPay 订单上送信息不全 终止上送", gson.toJson(userLoginInfoDto), ""); LogUtil.error("syncStatusOrderPay 订单上送信息不全 终止上送", gson.toJson(userLoginInfoDto), "");
return; return;
...@@ -138,7 +140,7 @@ public class WechatPushProcessor { ...@@ -138,7 +140,7 @@ public class WechatPushProcessor {
String mchId = null; String mchId = null;
if(StringUtils.isBlank(platformMchId)) { if(StringUtils.isBlank(platformMchId)) {
// 获取当前商户微信支付mchId // 获取当前商户微信支付mchId
AssortmentOpenPlatformWxapp wxApp = openPlatformWxappManager.findByPartnerIdAndWxappId(userLoginInfoDto.getPartnerId(), userLoginInfoDto.getWxAppid()); AssortmentOpenPlatformWxapp wxApp = openPlatformWxappManager.findByPartnerIdAndWxappId(userLoginInfoDto.getPartnerId(), userLoginInfoDto.getWxAppId());
if (wxApp == null || wxApp.getMchId() == null) { if (wxApp == null || wxApp.getMchId() == null) {
LogUtil.error("syncStatusOrderCreate 订单上送信息 未查询到商户号", gson.toJson(wxApp), ""); LogUtil.error("syncStatusOrderCreate 订单上送信息 未查询到商户号", gson.toJson(wxApp), "");
return; return;
...@@ -182,11 +184,11 @@ public class WechatPushProcessor { ...@@ -182,11 +184,11 @@ public class WechatPushProcessor {
* @param userLoginInfoDto * @param userLoginInfoDto
* @return * @return
*/ */
private OrderBody.SyncStatusInfo getSyncStatusInfo(String mchId, UserLoginInfoDto userLoginInfoDto) { private OrderBody.SyncStatusInfo getSyncStatusInfo(String mchId, AssortmentCustomerInfoVo userLoginInfoDto) {
OrderBody.SyncStatusInfo syncStatusInfo = new OrderBody.SyncStatusInfo(); OrderBody.SyncStatusInfo syncStatusInfo = new OrderBody.SyncStatusInfo();
syncStatusInfo.setMchId(mchId); syncStatusInfo.setMchId(mchId);
syncStatusInfo.setWxAppid(userLoginInfoDto.getWxAppid()); syncStatusInfo.setWxAppid(userLoginInfoDto.getWxAppId());
syncStatusInfo.setOpenId(userLoginInfoDto.getOpenId()); syncStatusInfo.setOpenId(userLoginInfoDto.getOpenId());
syncStatusInfo.setSessionKey(userLoginInfoDto.getSessionKey()); syncStatusInfo.setSessionKey(userLoginInfoDto.getSessionKey());
return syncStatusInfo; return syncStatusInfo;
...@@ -200,12 +202,12 @@ public class WechatPushProcessor { ...@@ -200,12 +202,12 @@ public class WechatPushProcessor {
* @param userLoginInfoDto * @param userLoginInfoDto
* @return * @return
*/ */
private OrderBody.SyncStatusInfo getSyncStatusInfo(String mchId, UserLoginInfoDto userLoginInfoDto, String paidNo, String outTradeNo private OrderBody.SyncStatusInfo getSyncStatusInfo(String mchId, AssortmentCustomerInfoVo userLoginInfoDto, String paidNo, String outTradeNo
, String endTransId, String terminalId) { , String endTransId, String terminalId) {
OrderBody.SyncStatusInfo syncStatusInfo = new OrderBody.SyncStatusInfo(); OrderBody.SyncStatusInfo syncStatusInfo = new OrderBody.SyncStatusInfo();
syncStatusInfo.setMchId(mchId); syncStatusInfo.setMchId(mchId);
syncStatusInfo.setWxAppid(userLoginInfoDto.getWxAppid()); syncStatusInfo.setWxAppid(userLoginInfoDto.getWxAppId());
syncStatusInfo.setOpenId(userLoginInfoDto.getOpenId()); syncStatusInfo.setOpenId(userLoginInfoDto.getOpenId());
syncStatusInfo.setSessionKey(userLoginInfoDto.getSessionKey()); syncStatusInfo.setSessionKey(userLoginInfoDto.getSessionKey());
syncStatusInfo.setTransactionId(paidNo); syncStatusInfo.setTransactionId(paidNo);
...@@ -222,8 +224,8 @@ public class WechatPushProcessor { ...@@ -222,8 +224,8 @@ public class WechatPushProcessor {
* @param userLoginInfoDto * @param userLoginInfoDto
* @return true 未开启 false 已开启插件 * @return true 未开启 false 已开启插件
*/ */
private boolean checkWechatOpenPlugin(UserLoginInfoDto userLoginInfoDto) { private boolean checkWechatOpenPlugin(AssortmentCustomerInfoVo userLoginInfoDto) {
List<WxappPluginVo> openPlatformWxappPluginBinds = openPlatformWxappPluginBindManager.queryByWxAppid(userLoginInfoDto.getWxAppid()); List<WxappPluginVo> openPlatformWxappPluginBinds = openPlatformWxappPluginBindManager.queryByWxAppid(userLoginInfoDto.getWxAppId());
List<WxappPluginVo> pluginVoList = openPlatformWxappPluginBinds.stream().filter(wxappPluginVo -> wxappPluginVo.getPluginAppid().equals(COUPON_PLUGINS)).filter(wxappPluginVo -> wxappPluginVo.getOperateStatus() == 1).collect(Collectors.toList()); List<WxappPluginVo> pluginVoList = openPlatformWxappPluginBinds.stream().filter(wxappPluginVo -> wxappPluginVo.getPluginAppid().equals(COUPON_PLUGINS)).filter(wxappPluginVo -> wxappPluginVo.getOperateStatus() == 1).collect(Collectors.toList());
if (CollectionUtils.isEmpty(pluginVoList) || pluginVoList.size() != 1) { if (CollectionUtils.isEmpty(pluginVoList) || pluginVoList.size() != 1) {
LogUtil.error("checkWechatOpenPlugin 订单上送信息 未开启优惠插件", gson.toJson(pluginVoList), ""); LogUtil.error("checkWechatOpenPlugin 订单上送信息 未开启优惠插件", gson.toJson(pluginVoList), "");
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
*/ */
package cn.freemud.service; package cn.freemud.service;
import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.service.process.WechatPush.WechatPushProcessor; import cn.freemud.service.process.WechatPush.WechatPushProcessor;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -34,16 +33,16 @@ public class WechatPushProcessorTest { ...@@ -34,16 +33,16 @@ public class WechatPushProcessorTest {
@Test @Test
public void syncStatusOrderCreateTest() { public void syncStatusOrderCreateTest() {
UserLoginInfoDto userLoginInfoDto = new UserLoginInfoDto(); // UserLoginInfoDto userLoginInfoDto = new UserLoginInfoDto();
userLoginInfoDto.setWxAppid("wxb78fb7c6218cb52c"); // userLoginInfoDto.setWxAppId("wxb78fb7c6218cb52c");
userLoginInfoDto.setSessionKey("G9m9zqlrTeNAqtmclsqkPg\u003d\u003d"); // userLoginInfoDto.setSessionKey("G9m9zqlrTeNAqtmclsqkPg\u003d\u003d");
userLoginInfoDto.setMobile("15956904546"); // userLoginInfoDto.setMobile("15956904546");
userLoginInfoDto.setPartnerId("1864"); // userLoginInfoDto.setPartnerId("1864");
userLoginInfoDto.setNewMemeber(false); // userLoginInfoDto.setNewMember(false);
userLoginInfoDto.setUnionId("okRmn1I4WUvHfcBNkPQ15ydnSJDA"); // userLoginInfoDto.setUnionId("okRmn1I4WUvHfcBNkPQ15ydnSJDA");
userLoginInfoDto.setOpenId("oORZK5JfpU-MkOV_tDFff8rz8ook"); // userLoginInfoDto.setOpenId("oORZK5JfpU-MkOV_tDFff8rz8ook");
String oId = "142674066768146957"; // String oId = "142674066768146957";
String companyId = "1864"; // String companyId = "1864";
// Assert.assertTrue( wechatPushProcessor.statusOrderCreate(userLoginInfoDto, oId,companyId) ); // Assert.assertTrue( wechatPushProcessor.statusOrderCreate(userLoginInfoDto, oId,companyId) );
} }
......
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