记得上下班打卡 | git大法好,push需谨慎

Commit f057722f authored by 胡佳晨's avatar 胡佳晨

支付回调 unfinish

parent 4e1de8a1
......@@ -7,6 +7,8 @@ import java.math.BigDecimal;
@Data
public class SyncOrderParam implements Cloneable {
@ApiModelProperty(value = "orderId")
private String orderId;
@ApiModelProperty(value = "status")
private Integer status;
@ApiModelProperty(value = "type")
......
......@@ -12,7 +12,7 @@ public interface IGoblinAppOrderService {
ResponseDto<GoblinPayInnerResultVo> payAgain(PayAgainParam param);
ResponseDto<GoblinPayInnerResultVo> syncOrder(SyncOrderParam syncOrderParam);
String syncOrder(SyncOrderParam syncOrderParam);
ResponseDto<Integer> checkOrderResult(String orderId);
}
package com.liquidnet.service.goblin.service;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinSelfMarketingVo;
import com.liquidnet.service.goblin.dto.vo.GoblinZhengzaiGoodVo;
import java.util.List;
public interface IGoblinStoreZhengzaiService {
/**
* 正在下单活动列表
*
* @return
*/
ResponseDto<List<GoblinSelfMarketingVo>> getZhengzaiMarketList();
/**
* 正在下单 商铺参与活动的商品列表
* @param marketId
* @return
*/
ResponseDto<List<GoblinZhengzaiGoodVo>> getSpuList(String marketId);
}
package com.liquidnet.service.goblin.controller;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinSelfMarketingVo;
import com.liquidnet.service.goblin.dto.vo.GoblinZhengzaiGoodVo;
import com.liquidnet.service.goblin.service.IGoblinStoreZhengzaiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
@Slf4j
@Api(tags = "正在下单相关")
@Api(tags = "正在下单相关-商铺")
@RestController
@RequestMapping("/zhengzai")
@RequestMapping("/zhengzai/store")
public class GoblinStoreZhengzaiController {
@Autowired
IGoblinStoreZhengzaiService goblinStoreZhengzaiService;
@GetMapping("market/list")
@ApiOperation("正在下单-活动列表")
public ResponseDto<List<GoblinSelfMarketingVo>> getZhengzaiMarketList() {
return goblinStoreZhengzaiService.getZhengzaiMarketList();
}
@GetMapping("spu/list")
@ApiOperation("正在下单-参与活动的spu")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动id", example = "1"),
})
public ResponseDto<List<GoblinZhengzaiGoodVo>> getStoreList(@RequestParam("marketId") @Valid String marketId) {
return goblinStoreZhengzaiService.getSpuList(marketId);
}
}
......@@ -403,18 +403,19 @@ public class GoblinAppOrderServiceImpl implements IGoblinAppOrderService {
return ResponseDto.failure("订单已支付");
}
GoblinPayInnerResultVo payInnerResultVo = GoblinPayInnerResultVo.getNew();
if (!storeOrderVo.getPayType().equals("FREE") && storeOrderVo.getPayType().equals(param.getPayType()) && storeOrderVo.getDeviceFrom().equals(param.getDeviceFrom())) {
payInnerResultVo.setCode(checkVo.getData().getCode());
payInnerResultVo.setOrderCode(checkVo.getData().getOrderCode());
payInnerResultVo.setPayData(checkVo.getData().getPayData());
payInnerResultVo.setOrderId(param.getOrderId());
payInnerResultVo.setPayType(param.getPayType());
payInnerResultVo.setPrice(storeOrderVo.getPriceActual());
storeOrderVo.setPayCode(payInnerResultVo.getCode());
payInnerResultVo.setShowUrl(param.getShowUrl() + storeOrderVo.getOrderId());
payInnerResultVo.setReturnUrl(param.getReturnUrl() + storeOrderVo.getOrderId());
log.info(UserPathDto.setData("再次支付[原支付方式]", param, payInnerResultVo));
} else {
// if (!storeOrderVo.getPayType().equals("FREE") && storeOrderVo.getPayType().equals(param.getPayType()) && storeOrderVo.getDeviceFrom().equals(param.getDeviceFrom())) {
// payInnerResultVo.setCode(checkVo.getData().getCode());
// payInnerResultVo.setOrderCode(checkVo.getData().getOrderCode());
// payInnerResultVo.setPayData(checkVo.getData().getPayData());
// payInnerResultVo.setOrderId(param.getOrderId());
// payInnerResultVo.setPayType(param.getPayType());
// payInnerResultVo.setPrice(storeOrderVo.getPriceActual());
// storeOrderVo.setPayCode(payInnerResultVo.getCode());
// payInnerResultVo.setShowUrl(param.getShowUrl() + storeOrderVo.getOrderId());
// payInnerResultVo.setReturnUrl(param.getReturnUrl() + storeOrderVo.getOrderId());
// log.info(UserPathDto.setData("再次支付[原支付方式]", param, payInnerResultVo));
// } else
if (!storeOrderVo.getPayType().equals("FREE")) {
// 调用支付
LinkedMultiValueMap<String, String> httpData = CollectionUtil.linkedMultiValueMapStringString();
httpData.add("type", "PRODUCT");
......@@ -457,14 +458,36 @@ public class GoblinAppOrderServiceImpl implements IGoblinAppOrderService {
payInnerResultVo.setReturnUrl(param.getReturnUrl() + storeOrderVo.getOrderId());
//mysql
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_AGAIN.getKey(),
SqlMapping.get("goblin.store.market.status", param.getPayType(), param.getDeviceFrom(), payInnerResultVo.getCode(), param.getOrderId(), now, now));
SqlMapping.get("goblin_order.pay.again", param.getPayType(), param.getDeviceFrom(), payInnerResultVo.getCode(), param.getOrderId(), now, now));
log.info(UserPathDto.setData("再次支付[新支付方式]", param, payInnerResultVo));
}
return ResponseDto.success(payInnerResultVo);
}
@Override
public ResponseDto<GoblinPayInnerResultVo> syncOrder(SyncOrderParam syncOrderParam) {
public String syncOrder(SyncOrderParam syncOrderParam) {
log.debug("SYNC PARAM = " + syncOrderParam.toString());
//支付时间
LocalDateTime now = LocalDateTime.now();
String timePay = syncOrderParam.getPaymentAt();
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(syncOrderParam.getOrderId());
if (orderVo == null) {
log.error("订单号:" + syncOrderParam.getOrderCode() + " 订单不存在");
return "fail";//订单不存在
}
if (orderVo.getStatus() != GoblinStatusConst.OrderStatus.ORDER_STATUS_0.getValue()) {
if (!orderVo.getPayCode().equals(syncOrderParam.getCode())) {
log.error("订单号:" + syncOrderParam.getOrderCode() + " 重复支付");
return "fail";//重复支付
}
}
if (orderVo.getPriceActual().compareTo(syncOrderParam.getPrice()) != 0) {
log.error("订单号:" + syncOrderParam.getOrderCode() + " 价格不符");
return "fail";//价格不符
}
LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlDataOrder = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlDataSku = CollectionUtil.linkedListObjectArr();
return null;
}
......@@ -479,8 +502,8 @@ public class GoblinAppOrderServiceImpl implements IGoblinAppOrderService {
return null;
}
String returnCheckData = HttpUtil.get(checkUrl + "?code=" + storeOrderVo.getPayCode(), null);
ResponseDto<SyncOrderParam> syncOrderDtoParam = JsonUtils.fromJson(returnCheckData, new TypeReference<ResponseDto<SyncOrderParam>>() {
});
ResponseDto<SyncOrderParam> syncOrderDtoParam = JsonUtils.fromJson(returnCheckData, new TypeReference<ResponseDto<SyncOrderParam>>() {
});
if (syncOrderDtoParam.getData().getStatus() == 1) {
//处理订单
syncOrder(syncOrderDtoParam.getData());
......
......@@ -64,7 +64,7 @@ public class GoblinAppZhengzaiServiceImpl implements IGoblinAppZhengzaiService {
List<GoblinZhengzaiGoodVo> voList = ObjectUtil.getGoblinZhengzaiGoodVoArrayList();
for (String spuId : spuIdList) {
GoblinGoodsInfoVo vo = redisUtils.getGoodsInfoVo(spuId);
if (vo.getStatus().equals("3")) {
if (vo.getStatus().equals("3") && storeId.equals(vo.getStoreId())) {
GoblinZhengzaiGoodVo returnVo = GoblinZhengzaiGoodVo.getNew();
BeanUtils.copyProperties(vo, returnVo);
voList.add(returnVo);
......
package com.liquidnet.service.goblin.service.impl;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.service.IGoblinStoreZhengzaiService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.ObjectUtil;
import com.liquidnet.service.goblin.util.QueueUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
@Service
public class GoblinStoreZhengzaiServiceImpl implements IGoblinStoreZhengzaiService {
......@@ -17,4 +29,52 @@ public class GoblinStoreZhengzaiServiceImpl implements IGoblinStoreZhengzaiServi
@Autowired
QueueUtils queueUtils;
@Override
public ResponseDto<List<GoblinSelfMarketingVo>> getZhengzaiMarketList() {
String uid = CurrentUtil.getCurrentUid();
GoblinStoreInfoVo storeInfoVo = redisUtils.getStoreInfoVoByUid(uid);
if (storeInfoVo == null) {
return ResponseDto.failure("店铺不存在");
}
String storeId = storeInfoVo.getStoreId();
List<String> marketIds = redisUtils.getStoreZhengzaiRelation(storeId);//可参加的正在活动id
List<GoblinSelfMarketingVo> list = redisUtils.getGoblinSelfMarketingVoList();//所有正在下单活动列表
List<GoblinSelfMarketingVo> voList = ObjectUtil.getGoblinSelfMarketingVoList();
LocalDateTime now = LocalDateTime.now();
for (GoblinSelfMarketingVo item : list) {
if (LocalDateTime.parse(item.getStartTime(), DTF_YMD_HMS).isBefore(now) && LocalDateTime.parse(item.getEndTime(), DTF_YMD_HMS).isAfter(now)) {
if (marketIds.contains(item.getSelfMarketId())) {
List<GoblinMarketRelationVo> relationVo = redisUtils.getMarketRelation(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue(), item.getSelfMarketId());
List<String> storeIdList = relationVo.stream().map(GoblinMarketRelationVo::getStoreId).distinct().collect(Collectors.toList());//配置了商铺的店铺
if (storeIdList.contains(storeId)) {
voList.add(item);
}
}
}
}
return ResponseDto.success(voList);
}
@Override
public ResponseDto<List<GoblinZhengzaiGoodVo>> getSpuList(String marketId) {
String uid = CurrentUtil.getCurrentUid();
GoblinStoreInfoVo storeInfoVo = redisUtils.getStoreInfoVoByUid(uid);
if (storeInfoVo == null) {
return ResponseDto.failure("店铺不存在");
}
String storeId = storeInfoVo.getStoreId();
List<GoblinMarketRelationVo> relationVo = redisUtils.getMarketRelation(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue(), marketId);
List<String> spuIdList = relationVo.stream().map(GoblinMarketRelationVo::getSpuId).collect(Collectors.toList());
List<GoblinZhengzaiGoodVo> voList = ObjectUtil.getGoblinZhengzaiGoodVoArrayList();
for (String spuId : spuIdList) {
GoblinGoodsInfoVo vo = redisUtils.getGoodsInfoVo(spuId);
if (vo.getStatus().equals("3") && vo.getStoreId().equals(storeId)) {
GoblinZhengzaiGoodVo returnVo = GoblinZhengzaiGoodVo.getNew();
BeanUtils.copyProperties(vo, returnVo);
voList.add(returnVo);
}
}
return ResponseDto.success(voList);
}
}
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