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

Commit 52bc19ae authored by 胡佳晨's avatar 胡佳晨

订单 需要入mogon skuVo需要拆

parent 52291f2d
......@@ -33,6 +33,8 @@ public class GoblinStatusConst {
ORDER_STATUS_5(5, "取消订单(用户未付款前取消订单)"),
ORDER_STATUS_6(6, "退款通过(用户已经付款但是商城还未发货,用户发出退款申请,商城同意退款)"),
ORDER_STATUS_7(7, "退货通过(用户已经确认收货后用户发出退货申请,商城同意所有退货申请 ,一个订单可能有多个单品)"),
ORDER_STATUS_61(61, "发起-退款通过(用户已经付款但是商城还未发货,用户发出退款申请,商城同意退款)"),
ORDER_STATUS_71(71, "发起-退货通过(用户已经确认收货后用户发出退货申请,商城同意所有退货申请 ,一个订单可能有多个单品)"),
;
private final int value;
......
......@@ -34,6 +34,8 @@ public class GoblinOrderSkuVo implements Serializable, Cloneable {
private String skuId;
@ApiModelProperty(value = "数量")
private Integer num;
@ApiModelProperty(value = "订单状态[0-待付款(用户刚下单)|2-代发货(用户付完款 等待商城发货)|3-代收货(商城已经发货 等待用户确认收货)|4-已完成(用户已经确认收货 订单结束)|5-取消订单(用户未付款前取消订单)|6-退款通过(用户已经付款但是商城还未发货,用户发出退款申请,商城同意退款)|7-退货通过(用户已经确认收货后用户发出退货申请,商城同意所有退货申请 ,一个订单可能有多个单品)|61-6的发起状态|71-7的发起状态]")
private int status;
@ApiModelProperty(value = "款式原价")
private BigDecimal skuPrice;
@ApiModelProperty(value = "款式实付价")
......
......@@ -45,6 +45,11 @@ public class GoblinOrderSku implements Serializable,Cloneable {
*/
private String skuId;
/**
* 状态 同order
*/
private Integer status;
/**
* 数量
*/
......
......@@ -150,6 +150,8 @@ public class GoblinStoreOrder implements Serializable,Cloneable {
*/
private String payType;
private String paymentType;
private String paymentId;
/**
* 支付来源
*/
......
......@@ -48,6 +48,12 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-common-sms</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
......
package com.liquidnet.service.goblin.controller.manage;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ApiSupport(order = 149002)
@Api(tags = "店铺资金模块")
@Slf4j
@Validated
@RestController
@RequestMapping("store/money")
public class GoblinStoreMoneyController {
@Autowired
GoblinRedisUtils goblinRedisUtils;
}
......@@ -5,10 +5,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.adam.dto.vo.AdamAddressesVo;
import com.liquidnet.service.adam.dto.vo.AdamRscPolymer01Vo;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.UserPathDto;
import com.liquidnet.service.base.*;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.manage.GoblinOrderParam;
......@@ -200,7 +197,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
GoblinGoodsSkuInfoVo skuVo = redisUtils.getGoodsSkuInfoVo(skuParam.getSkuId());
skuName = skuName.concat(skuVo.getName()).concat(",");
if (pre != null && pre.contains(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue())) {
writeOffCode = IDGenerator.getWriteOffCode();
writeOffCode = "EMPTY";
}
//获得 商品原价和活动价格
priceBase = skuVo.getPrice();
......@@ -228,6 +225,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
GoblinOrderSku orderSku = GoblinOrderSku.getNew();
orderSku.setOrderSkuId(IDGenerator.nextTimeId2());
orderSku.setOrderId(orderId);
orderSku.setStatus(GoblinStatusConst.OrderStatus.ORDER_STATUS_0.getValue());
orderSku.setSpuId(skuParam.getSpuId());
orderSku.setSkuId(skuParam.getSkuId());
orderSku.setNum(skuParam.getNumber());
......@@ -511,31 +509,101 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
log.debug("SYNC PARAM = " + syncOrderParam.toString());
//支付时间
LocalDateTime now = LocalDateTime.now();
String timePay = syncOrderParam.getPaymentAt();
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(syncOrderParam.getOrderCodeId());
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";//重复支付
String[] array = syncOrderParam.getOrderCodeId().split(",");
String uid = "0";
BigDecimal priceActual = BigDecimal.ZERO;
for (String orderId : array) {
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(orderId);
priceActual = priceActual.add(orderVo.getPriceActual());
uid = orderVo.getUserId();
if (orderVo == null) {
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();
if (orderVo.getStatus() == GoblinStatusConst.OrderStatus.ORDER_STATUS_5.getValue() && syncOrderParam.getStatus().equals(1)) {
log.error("订单号为 {} 的订单超时支付", syncOrderParam.getOrderCode());
} else if ((orderVo.getStatus() == GoblinStatusConst.OrderStatus.ORDER_STATUS_6.getValue() || orderVo.getStatus() == GoblinStatusConst.OrderStatus.ORDER_STATUS_7.getValue()) && syncOrderParam.getStatus().equals(1)) {
log.error("订单号为 {} 的订单正在退款 或者已退款", syncOrderParam.getOrderCode());
} else if (syncOrderParam.getStatus().equals(1)) {
log.error("订单号为 {} 的订单正常流程", syncOrderParam.getOrderCode());
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();
GoblinStoreOrder storeOrder = GoblinStoreOrder.getNew();
if (orderVo.getStatus() == GoblinStatusConst.OrderStatus.ORDER_STATUS_5.getValue() && syncOrderParam.getStatus().equals(1)) {
log.error("订单号为 {} 的订单超时支付", syncOrderParam.getOrderCode());
// todo 操作超时支付
// orderVo.setStatus(GoblinStatusConst.OrderStatus.ORDER_STATUS_61.getValue());
// redisUtils.setGoblinOrder(orderVo.getOrderId(),orderVo);
} else if ((orderVo.getStatus() == GoblinStatusConst.OrderStatus.ORDER_STATUS_6.getValue() || orderVo.getStatus() == GoblinStatusConst.OrderStatus.ORDER_STATUS_7.getValue()) && syncOrderParam.getStatus().equals(1)) {
log.error("订单号为 {} 的订单正在退款 或者已退款", syncOrderParam.getOrderCode());
} else if (syncOrderParam.getStatus().equals(1)) {
log.error("订单号为 {} 的订单正常流程", syncOrderParam.getOrderCode());
storeOrder.setPaymentType(syncOrderParam.getPaymentType());
storeOrder.setPaymentId(syncOrderParam.getPaymentId());
storeOrder.setPayCode(syncOrderParam.getCode());
storeOrder.setPayTime(now);
if (orderVo.getWriteOffCode().equals("EMPTY")) {
storeOrder.setWriteOffCode(IDGenerator.getWriteOffCode());
} else {
storeOrder.setWriteOffCode("");
}
storeOrder.setStatus(GoblinStatusConst.OrderStatus.ORDER_STATUS_2.getValue());
storeOrder.setUpdatedAt(now);
sqls.add(SqlMapping.get("goblin_order.pay.order"));
sqlDataOrder.add(new Object[]{
storeOrder.getPaymentType(), storeOrder.getPaymentId(), storeOrder.getPayCode(), storeOrder.getPayTime(), storeOrder.getWriteOffCode(), storeOrder.getStatus(), storeOrder.getUpdatedAt(),
orderId, now, now
});
sqls.add(SqlMapping.get("goblin_order.pay.sku"));
List<GoblinOrderSkuVo> skuList = orderVo.getOrderSkuVos();
for (GoblinOrderSkuVo orderSkuVo : skuList) {
//增加销量
redisUtils.incrSkuSaleCount(orderSkuVo.getSkuId(), orderSkuVo.getNum());
orderSkuVo.setStatus(GoblinStatusConst.OrderStatus.ORDER_STATUS_2.getValue());
sqlDataSku.add(new Object[]{
GoblinStatusConst.OrderStatus.ORDER_STATUS_2.getValue(), now,
orderSkuVo.getOrderSkuId(), now, now
});
}
//redis
orderVo.setPayCode(storeOrder.getPayCode());
orderVo.setPayTime(storeOrder.getPayTime());
orderVo.setWriteOffCode(storeOrder.getWriteOffCode());
orderVo.setStatus(storeOrder.getStatus());
orderVo.setOrderSkuVos(skuList);
redisUtils.setGoblinOrder(orderId, orderVo);
//删除未支付订单
redisUtils.removeGoblinOrder(null, orderId);
//mongo
mongoUtils.insertGoblinStoreOrderVo(orderVo);
//mysql
queueUtils.sendMsgByRedis(MQConst.KylinQueue.SQL_ORDER_CREATE.getKey(),
SqlMapping.gets(sqls, sqlDataOrder, sqlDataSku));
}
//发短信
// SmsEnum.ADTemplate adTemplate = null;
// if (orderTicketData.getGetTicketType().equals("express")) {
// adTemplate = SmsEnum.ADTemplate.SMS_225995308;
// } else if (orderTicketData.getGetTicketType().equals("electronic")) {
// adTemplate = ticketData.getIsShowCode() == 1 ? SmsEnum.ADTemplate.SMS_225995308 : SmsEnum.ADTemplate.SMS_225995308;
// }
//
// if (null != adTemplate) {
// queueUtils.sendMsgByRedis(MQConst.KylinQueue.SMS_NOTICE.getKey(),
// SmsMessage.builder().setPhone(orderTicketData.getUserMobile())
// .setSignName(SmsEnum.ADSignName.M02.getVal())
// .setTemplateCode(adTemplate.name())
// .setTemplateParam("name", orderTicketData.getPerformanceTitle())
// .setTemplateParam("time", time1 + " " + time2).toJson()
// );
// }
//加分
orderUtils.doTask(uid, priceActual);
}
return "success";
}
......
......@@ -332,4 +332,9 @@ public class GoblinMongoUtils {
List<GoblinSelfMarketingVo> voList = mongoTemplate.find(Query.query(Criteria.where("type").is(2).and("status").ne(7).and("endTime").gte(nowStr).and("startTime").lte(nowStr)), GoblinSelfMarketingVo.class, GoblinSelfMarketingVo.class.getSimpleName());
return voList;
}
//添加 订单vo全量
public GoblinStoreOrderVo insertGoblinStoreOrderVo(GoblinStoreOrderVo vo) {
return mongoTemplate.insert(vo, GoblinStoreOrderVo.class.getSimpleName());
}
}
......@@ -121,4 +121,19 @@ public class GoblinOrderUtils {
return hashMap;
}
}
public void doTask(String uid, BigDecimal price) {
try {
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Accept", "application/json;charset=UTF-8");
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("score", price.intValue() + "");
params.add("content", "购买商品:");
params.add("uid", uid);
String resultData = HttpUtil.post(stoneUrl + "/user/logs/in2111", params, header);
} catch (Exception e) {
log.error("添加积分失败,e:{}", e);
e.printStackTrace();
}
}
}
......@@ -421,76 +421,88 @@ public class GoblinRedisUtils {
}
// 赋值 订单相关vo
public void setGoblinOrder(String orderId,GoblinStoreOrderVo vo){
public void setGoblinOrder(String orderId, GoblinStoreOrderVo vo) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER.concat(orderId);
redisUtil.set(redisKey,vo);
redisUtil.set(redisKey, vo);
}
// 赋值 订单相关vo
public GoblinStoreOrderVo getGoblinOrder(String orderId){
public GoblinStoreOrderVo getGoblinOrder(String orderId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER.concat(orderId);
Object obj = redisUtil.get(redisKey);
if(obj==null){
if (obj == null) {
return null;
}else{
} else {
return (GoblinStoreOrderVo) obj;
}
}
// 获取 未支付订单id列表
public List<String> getUnPayOrder(){
int randomKey=RandomUtil.getRandomInt(0,100);
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_UN_PAY.concat(randomKey+"");
public List<String> getUnPayOrder() {
int randomKey = RandomUtil.getRandomInt(0, 100);
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_UN_PAY.concat(randomKey + "");
Object obj = redisUtil.get(redisKey);
if(obj==null){
if (obj == null) {
return CollectionUtil.arrayListString();
}else{
} else {
return (List<String>) obj;
}
}
// 添加 未支付订单id列表
public void addUnPayOrder(String orderId){
int randomKey=RandomUtil.getRandomInt(0,100);
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_UN_PAY.concat(randomKey+"");
public void addUnPayOrder(String orderId) {
int randomKey = RandomUtil.getRandomInt(0, 100);
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_UN_PAY.concat(randomKey + "");
List<String> list = getUnPayOrder();
list.add(orderId);
redisUtil.set(redisKey,list);
redisUtil.set(redisKey, list);
}
// 删除 未支付订单id列表
public void removeGoblinOrder(String randomKey ,String orderId){
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_UN_PAY.concat(randomKey+"");
List<String> list = getUnPayOrder();
list.remove(orderId);
redisUtil.set(redisKey,list);
public void removeGoblinOrder(String randomKey, String orderId) {
if (randomKey == null) {
for (int i = 0; i < 100; i++) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_UN_PAY.concat(i + "");
List<String> list = getUnPayOrder();
if(list.contains(orderId)){
list.remove(orderId);
redisUtil.set(redisKey, list);
break;
}
}
} else {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_UN_PAY.concat(randomKey + "");
List<String> list = getUnPayOrder();
list.remove(orderId);
redisUtil.set(redisKey, list);
}
}
// 获取 订单id列表
public List<String> getOrderList(String uid){
public List<String> getOrderList(String uid) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_LIST.concat(uid);
Object obj = redisUtil.get(redisKey);
if(obj==null){
if (obj == null) {
return CollectionUtil.arrayListString();
}else{
} else {
return (List<String>) obj;
}
}
// 添加 订单id列表
public void addOrderList(String uid,String orderId){
public void addOrderList(String uid, String orderId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_LIST.concat(uid);
List<String> list = getOrderList(uid);
list.add(orderId);
redisUtil.set(redisKey,list);
redisUtil.set(redisKey, list);
}
// 删除 订单id列表
public void removeOrderList(String uid ,String orderId){
public void removeOrderList(String uid, String orderId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_LIST.concat(uid);
List<String> list = getOrderList(uid);
list.remove(orderId);
redisUtil.set(redisKey,list);
redisUtil.set(redisKey, list);
}
}
......@@ -13,8 +13,8 @@ goblin.self.market.delSpuRelation=UPDATE goblin_marketing_zhengzai SET del_flag
goblin.order.create.order_insert=INSERT INTO goblin_store_order (`master_order_code`,`order_id`,`store_id`,`order_code`,`user_id`,`user_name`,`user_mobile`,`price_total`,`price_actual`,`price_refund`,`price_express`,`price_coupon`,`price_voucher`,`status`,`ucoupon_id`,`pay_type`,`device_from`,`source`,`version`,`is_member`,`order_type`,`write_off_code`,`pay_countdown_minute`,`ip_address`,`pay_code`,`created_at`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin.order.create.attr_insert=INSERT INTO goblin_order_attr (`order_attr_id`,`order_id`,`express_contacts`,`express_address`,`express_address_detail`,`express_phone`,`express_type`,`created_at`) VALUES (?,?,?,?,?,?,?,?)
goblin.order.create.sku_insert=INSERT INTO goblin_order_sku (`order_sku_id`,`order_id`,`spu_id`,`sku_id`,`num`,`sku_price`,`sku_price_actual`,`sku_name`,`sku_no`,`sku_image`,`sku_specs`,`price_voucher`,`created_at`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin_order.pay.order = UPDATE goblin_store_order SET pay_type = ? ,device_from = ? ,pay_code = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.pay.sku = UPDATE goblin_store_order SET pay_type = ? ,device_from = ? ,pay_code = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.pay.order=UPDATE goblin_store_order SET payment_type = ? ,payment_id=?,pay_code = ? ,pay_time = ?,write_off_code = ? ,status = ? ,updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.pay.sku=UPDATE goblin_order_sku SET status = ? ,updated_at = ? WHERE order_sku_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
#---- 再次支付
goblin_order.pay.again = UPDATE goblin_store_order SET pay_type = ? ,device_from = ? ,pay_code = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.pay.again=UPDATE goblin_store_order SET pay_type = ? ,device_from = ? ,pay_code = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
#---- 订单关闭
\ No newline at end of file
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