Commit 349978d3 by guojuxing

微盟商城回调

parent 71a356a9
......@@ -5,8 +5,12 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.gic.enterprise.base.UserInfo;
import com.gic.enterprise.error.ErrorCode;
import com.gic.goods.pump.api.service.WeiMobGoodsService;
import com.gic.member.config.api.enums.OrderPointCalculationPartyEnum;
import com.gic.member.config.api.service.OrderPointCalculationPartyApiService;
import com.gic.redis.data.util.RedisUtil;
import com.gic.weimob.api.service.WeimobBaseService;
import com.gic.weimob.api.service.WeimobMemberService;
import org.apache.commons.collections.CollectionUtils;
......@@ -57,10 +61,14 @@ public class WmMallStoreController {
private WeimobBaseService weimobBaseService;
@Autowired
private WeiMobGoodsService weiMobGoodsService;
@Autowired
private OrderPointCalculationPartyApiService orderPointCalculationPartyApiService;
@RequestMapping("/save-wm-store")
public RestResponse save(WmStoreDTO dto) {
dto.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
UserInfo userInfo = UserDetailUtils.getUserDetail().getUserInfo();
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
dto.setEnterpriseId(enterpriseId);
ServiceResponse<Integer> result = wmStoreApiService.saveWmStore(dto);
if (result.isSuccess()) {
//创建微盟gic关联
......@@ -69,6 +77,10 @@ public class WmMallStoreController {
dto.getWmMainAccount(), Long.valueOf(dto.getWmPid()), Long.valueOf(dto.getWmStoreId()),
MallModeEnum.mapToWm(dto.getMallMode()));
LOGGER.info("微盟商城店铺-微盟结果:{}", JSON.toJSONString(saveStoreInfo));
ServiceResponse<Void> response = orderPointCalculationPartyApiService
.saveOrderPointCalculationParty(enterpriseId, Long.valueOf(result.getResult()),
dto.getWmPidName(), userInfo.getUserId(), userInfo.getUserName(), OrderPointCalculationPartyEnum.WEIMO.getCode());
LOGGER.info("微盟商城店铺-会员组初始化结果:{}", JSON.toJSONString(response));
}
return OperationResultUtils.operationResult(result,
OperationResultUtils.LOG_NEW + "微盟商城店铺", dto.getWmPidName());
......@@ -145,7 +157,10 @@ public class WmMallStoreController {
ServiceResponse<String> response = weimobMerchantService.getAuthUrl();
if (response.isSuccess()) {
String authUrl = response.getResult();
String mainHost = DomainUtils.getCurrentDomain() + "/wm-mall-store/auth-callback?wmMallStoreId=" + wmMallStoreId;
String mainHost = DomainUtils.getCurrentDomain() + "/wm-mall-store/auth-callback";
//为了授权回调取用的店铺主键ID
RedisUtil.setCache("enterprise:wm:auth:" + UserDetailUtils.getUserDetail().getEnterpriseId(), wmMallStoreId);
return RestResponse.success(authUrl + "&redirect_uri=" + mainHost);
} else {
return RestResponse.failure(response.getCode(), response.getMessage());
......@@ -315,20 +330,26 @@ public class WmMallStoreController {
* @param code
*/
@RequestMapping("auth-callback")
@ResponseBody
public void authCallBack(String code, Integer wmMallStoreId) throws IOException {
public void authCallBack(String code) throws IOException {
try {
ServiceResponse<Void> authWmResponse = weimobMerchantService.weimobStoreAuth(wmMallStoreId, code);
Object obj = RedisUtil.getCache("enterprise:wm:auth:" + UserDetailUtils.getUserDetail().getEnterpriseId());
if (obj == null) {
LOGGER.warn("微盟授权-店铺ID缓存不存在");
}
ServiceResponse<Void> authWmResponse = weimobMerchantService.weimobStoreAuth((Integer) obj, code);
LOGGER.info("微盟中间件返回结果:{}", JSON.toJSONString(authWmResponse));
if (authWmResponse.isSuccess()) {
//更新gic侧店铺授权状态
ServiceResponse<String> wmMallStoreResponse = wmStoreApiService.authWmStore(wmMallStoreId);
ServiceResponse<String> wmMallStoreResponse = wmStoreApiService.authWmStore((Integer) obj);
if (!wmMallStoreResponse.isSuccess()) {
LOGGER.warn("企业侧微盟店铺授权结果:{}", JSON.toJSONString(wmMallStoreResponse));
}
}
} catch (Exception e) {
LOGGER.warn("微盟授权返回结果:{}", e.getMessage(), e);
} finally {
//清空缓存
RedisUtil.delCache("enterprise:wm:auth:" + UserDetailUtils.getUserDetail().getEnterpriseId());
}
}
......
......@@ -135,4 +135,5 @@
<dubbo:reference interface="com.gic.store.service.ClerkApiService" id="clerkApiService" timeout="60000" />
<dubbo:reference interface="com.gic.goods.pump.api.service.WeiMobGoodsService" id="weiMobGoodsService" timeout="60000" />
<dubbo:reference interface="com.gic.member.config.api.service.OrderPointCalculationPartyApiService" id="orderPointCalculationPartyApiService" timeout="60000" />
</beans>
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