Authored by caoyan

Merge branch 'test6.8.5' of http://git.yoho.cn/ufo/yohoufo-fore into test6.8.5

Showing 26 changed files with 556 additions and 123 deletions
... ... @@ -13,7 +13,7 @@
id, product_id, size_id, skn_price, sku_price, create_time
</sql>
<select id="selectByProductId" resultMap="BaseResultMap">
select
select
<include refid="Base_Column_List" />
from price_trend_day
where product_id = #{productId, jdbcType=INTEGER}
... ... @@ -22,7 +22,7 @@
</if>
AND create_time &gt;= #{startTime, jdbcType=INTEGER}
AND create_time &lt; #{endTime, jdbcType=INTEGER}
<if test="sizeId = null or sizeId =''">
<if test="sizeId == null or sizeId == ''">
GROUP BY product_id, create_time
</if>
ORDER BY create_time ASC
... ...
... ... @@ -23,7 +23,7 @@
</if>
AND create_time &gt;= #{startTime, jdbcType=INTEGER}
AND create_time &lt; #{endTime, jdbcType=INTEGER}
<if test="sizeId = null or sizeId =''">
<if test="sizeId == null or sizeId == ''">
GROUP BY product_id, create_time
</if>
ORDER BY create_time ASC
... ...
... ... @@ -23,7 +23,7 @@
</if>
AND create_time &gt;= #{startTime, jdbcType=INTEGER}
AND create_time &lt; #{endTime, jdbcType=INTEGER}
<if test="sizeId = null or sizeId =''">
<if test="sizeId == null or sizeId == ''">
GROUP BY product_id, create_time
</if>
ORDER BY create_time ASC
... ...
... ... @@ -23,7 +23,7 @@
</if>
AND create_time &gt;= #{startTime, jdbcType=INTEGER}
AND create_time &lt; #{endTime, jdbcType=INTEGER}
<if test="sizeId = null or sizeId =''">
<if test="sizeId == null or sizeId == ''">
GROUP BY product_id, create_time
</if>
ORDER BY create_time ASC
... ...
... ... @@ -5,5 +5,6 @@
<configuration>
<settings>
<setting name="defaultStatementTimeout" value="10"/> <!-- seconds -->
<setting name="logImpl" value="STDOUT_LOGGING" /> <!-- 在控制台打印sql语句 -->
</settings>
</configuration>
\ No newline at end of file
... ...
package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.resp.EntryThreshold;
import com.yohobuy.ufo.model.order.resp.SellerResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.order.model.request.ShoppingRequest;
import com.yohoufo.order.model.response.OrderSubmitResponse;
import com.yohoufo.order.service.IStoredSellerDepositService;
import com.yohoufo.order.service.IStoredSellerService;
import com.yohoufo.order.service.impl.SellerService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -14,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
... ... @@ -33,6 +40,9 @@ public class StoredSellerDepositController {
@Autowired
private IStoredSellerService storedSellerService;
@Autowired
private SellerService sellerService;
/**
* 预存保证金
*/
... ... @@ -86,7 +96,7 @@ public class StoredSellerDepositController {
throw new GatewayException(400, "参数错误,uid不存在!");
}
Map<String,Boolean> map=storedSellerService.entryStatus(uid);
SellerResp map = storedSellerService.entryStatus(uid);
ApiResponse apiResponse = new ApiResponse();
apiResponse.setData(map);
return apiResponse;
... ... @@ -111,4 +121,15 @@ public class StoredSellerDepositController {
return apiResponse;
}
@RequestMapping(params = "method=ufo.seller.entryThresholds")
@ResponseBody
public ApiResponse getEntryThresholds() {
Map<EntrySellerType,EntryThreshold> data = sellerService.getEntryThreshold();
logger.info("enter ufo.seller.entryThresholds data {}", data);
return new ApiResponse.ApiResponseBuilder().data(data).code(200).message("升级预充值阈值").build();
}
}
... ...
package com.yohoufo.order.convert.builder;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.order.constants.AlarmConfig;
import java.util.Objects;
/**
* Created by chao.chen on 2019/1/10.
*/
public class AlarmEventBuilder {
public static SmsAlarmEvent buildRefundSellerEarnestMoneyAlarmEvent(OrderStatus orderStatus,Integer sellerUid, Long orderCode){
return new SmsAlarmEvent();
}
public static SmsAlarmEvent buildRefundBuyerGoodsMoneyAlarmEvent(OrderStatus orderStatus,Integer buyerUid, Long orderCode){
SmsAlarmEvent smsAlarmEvent = null;
String content = Objects.nonNull(orderStatus) ? orderStatus.getDesc() + ",用户" + buyerUid + "订单"+ orderCode +"退货款失败" : "";
AlarmConfig alarmConfig;
switch(orderStatus){
case CHECKING_FAKE:
alarmConfig = AlarmConfig.APPRAISE_FAIL;
smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getRefundName(), alarmConfig.name(), content);
break;
case SELLER_CANCEL_AFTER_PAY:
alarmConfig = AlarmConfig.SELLER_PLAY_BUYER;
smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getRefundName(), alarmConfig.name(), content);
break;
case BUYER_CANCEL_BEFORE_SELLER_DELIVER:
case BUYER_CANCEL_BEFORE_DEPOT_RECEIVE:
smsAlarmEvent = new SmsAlarmEvent("buyerPaidOrder.selfCancel", "cancel", content);
break;
}
return smsAlarmEvent;
}
}
... ...
... ... @@ -39,5 +39,6 @@ public class ShoppingRequest {
private String amount;
private int asSuper;
}
... ...
... ... @@ -30,6 +30,7 @@ import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.impl.SellerAddressService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
import com.yohoufo.order.utils.BuyerOrderUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -78,21 +79,35 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setOrderCode(orderInfo.getOrderCode());
buyerOrder.setUid(uid);
buyerOrder.setStatus(OrderStatus.HAS_PAYED.getCode());
int orderStatusCode = OrderStatus.HAS_PAYED.getCode();
//门店订单支付后直接完成
if(BuyerOrderUtils.isOffline(orderInfo)) {
orderStatusCode = OrderStatus.DONE.getCode();
}
buyerOrder.setStatus(orderStatusCode);
buyerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
int result = buyerOrderMapper.updateByOrderCode(buyerOrder);
//
if(result>0){
//记录状态信息
logger.info("in updateOrderStatusPaid record status change, orderCode {}", orderInfo.getOrderCode());
orderStatusFlowService.addAsy(orderInfo.getOrderCode(), OrderStatus.HAS_PAYED.getCode());
logger.info("in updateOrderStatusPaid record status change, orderCode {}, status: {}",
orderInfo.getOrderCode(), orderStatusCode);
orderStatusFlowService.addAsy(orderInfo.getOrderCode(), orderStatusCode);
}
orderInfo.setStatus(OrderStatus.HAS_PAYED.getCode());
orderInfo.setStatus(orderStatusCode);
return result;
}
@Override
public void processAfterPay(OrderInfo orderInfo) {
if(BuyerOrderUtils.isOrderDone(orderInfo)) {
logger.info("order status is Done, orderCode: {}, uid: {}", orderInfo.getOrderCode(), orderInfo.getUid());
return;
}
Integer uid = orderInfo.getUid();
Integer sellerUid = orderInfo.getSellerUid();
long orderCode = orderInfo.getOrderCode();
... ... @@ -292,6 +307,7 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
.amount(buyerOrder.getAmount())
.createTime(buyerOrder.getCreateTime())
.orderCodeType(OrderCodeType.BUYER_TYPE)
.attributes(buyerOrder.getAttributes())
.sourceStatus(buyerOrder.getStatus())
.payExpireTime(DelayTime.BUYER_ORDER_WAITING_PAY)
.build();
... ...
package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.resp.SellerResp;
import com.yohoufo.dal.order.model.StoredSeller;
import java.util.Map;
... ... @@ -11,7 +12,7 @@ public interface IStoredSellerService {
boolean isStoredSeller(Integer uid);
Map<String,Boolean> entryStatus(Integer uid);
SellerResp entryStatus(Integer uid);
void addUserAsStoredSeller(Integer uid);
... ...
... ... @@ -10,6 +10,7 @@ import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.resp.EntryThreshold;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
import com.yohoufo.common.utils.TimeUtils;
... ... @@ -24,6 +25,7 @@ import com.yohoufo.order.service.impl.SellerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
... ... @@ -32,6 +34,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
... ... @@ -62,7 +65,23 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
@Autowired
IStoredSellerService storedSellerService;
//@Value("${order.seller.tip.publishMoneyTip:保证金余额不足}")
private String publishMoneyTip = "保证金余额不足";
//@Value("${order.seller.tip.publishFunctionTip:请充值后进行正常上架/下架}")
private String publishFunctionTip = "请充值后进行正常上架/下架";
//@Value("${order.seller.tip.canSaleMoneyTip:保证金余额低于}")
private String canSaleMoneyTip = "保证金余额低于";
//@Value("${order.seller.tip.canSaleFunctionTip:平台下架您所有出售中的商品}")
private String canSaleFunctionTip = "平台下架您所有出售中的商品";
//@Value("${order.seller.tip.recoverTip:充值 ¥{} 恢复超级商家权限}")
private String recoverTip = "充值 ¥{} 恢复超级商家权限";
/**
* 更新订单状态
* @param orderInfo
... ... @@ -83,21 +102,16 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
@Override
public void processAfterPay(OrderInfo orderInfo) {
logger.info("充值后回调,处理processAfterPay,orderInfo={}", orderInfo);
// 首次充值,调用认证成功接口
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
try {
logger.info("首次充值后回调,调用商家入驻接口,uid={}", orderInfo.getUid());
storedSellerService.addUserAsStoredSeller(orderInfo.getUid());
} catch (Exception e) {
logger.error("首次充值后回调,商家入驻接口失败,uid={}, msg={}", orderInfo.getUid(), e.getMessage());
CommonAlarmEventPublisher.publish("商家入驻失败", "ufo.user.addUserAsStoredSeller", "首次充值后回调,商家入驻接口失败:uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode() + ",err="+ e.getMessage());
return;
}
}
BigDecimal amount = orderInfo.getAmount();
BigDecimal beforeAmount = BigDecimal.ZERO;
BigDecimal beforeLockAmount = BigDecimal.ZERO;
BigDecimal afterAmount = BigDecimal.ZERO;
BigDecimal afterLockAmount = BigDecimal.ZERO;
SellerWallet sw = sellerWalletMapper.selectByUidAndType(orderInfo.getUid(), 1);
logger.info("充值后回调,处理总账表,orderCode={}", orderInfo.getOrderCode());
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
... ... @@ -118,6 +132,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
logger.info("首次充值后回调,处理总账表新增账号,bean={}", sw);
sellerWalletMapper.insert(sw);
logger.info("首次充值后回调,处理总账表新增账号成功,bean={}", sw);
afterAmount = orderInfo.getAmount();
} else {
// 修改钱包余额
if (sw == null) {
... ... @@ -130,10 +147,25 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
CommonAlarmEventPublisher.publish("充值保证金余额失败", "ufo.order.recharge", "钱包不可用uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode()+", 充值金额为:"+amount);
return;
}
beforeAmount = sw.getAmount();
beforeLockAmount = sw.getLockAmount();
sw.setLockAmount(null);
sw.setAmount(orderInfo.getAmount());
EntrySellerType sellerType = sellerService.getEntrySellerType(orderInfo.getUid());
if (sellerType == EntrySellerType.SPECIAL_SUPER) {
// 白名单:充入lock账户
sw.setLockAmount(orderInfo.getAmount());
sw.setAmount(null);
afterAmount = beforeAmount;
afterLockAmount = beforeLockAmount.add(orderInfo.getAmount());
} else {
sw.setLockAmount(null);
sw.setAmount(orderInfo.getAmount());
afterAmount = beforeAmount.add(orderInfo.getAmount());
afterLockAmount = beforeLockAmount;
}
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
logger.info("后期充值,处理总账表增加余额,bean={}", sw);
if (sellerWalletMapper.addMoney(sw) == 0) {
... ... @@ -155,13 +187,8 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
swd.setType(SellerWalletDetail.Type.RE_CHARGE.getValue());
swd.setCreateTime(TimeUtils.getTimeStampSecond());
swd.setUpdateTime(0);
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
swd.setAvailAmount(orderInfo.getAmount());
swd.setLockAmount(BigDecimal.ZERO);
} else {
swd.setAvailAmount(orderInfo.getAmount().add(beforeAmount));
swd.setLockAmount(beforeLockAmount);
}
swd.setAvailAmount(afterAmount);
swd.setLockAmount(afterLockAmount);
swd.setIsSet(1);
MerchantOrderAttachInfo att = new MerchantOrderAttachInfo();
att.setPayment(orderInfo.getPayment());
... ... @@ -173,10 +200,16 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
logger.info("充值后,处理增加钱包明细,bean={}", swd);
sellerWalletDetailMapper.insert(swd);
logger.info("充值后,处理增加钱包明细成功,orderCode={}", orderInfo.getOrderCode());
// 身份升级、恢复等
logger.info("卖家{}此充值完成身份处理:{},orderCode={}", orderInfo.getUid());
sellerDealAfterPay(orderInfo.getUid(), orderInfo.getOrderCode(), afterAmount.add(afterLockAmount));
}
private void sellerDealAfterPay(Integer uid, long orderCode, BigDecimal allMoney) {
sellerService.processApply(uid, orderCode, allMoney);
}
/**
* 订单是否是待支付状态
* @param orderInfo
... ... @@ -334,11 +367,34 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
StoredSeller storedSeller =storedSellerService.getValidStoredSeller(uid);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
JSONObject result = new JSONObject();
result.put("all", sw.getAmount().add(sw.getLockAmount()).setScale(2).toString());
BigDecimal allMoney = sw.getAmount().add(sw.getLockAmount());
Map<EntrySellerType, EntryThreshold> map = sellerService.getEntryThreshold();
EntryThreshold sp = map.get(EntrySellerType.SUPER_ENTRY);
// 查配置、超级卖家门槛金额
BigDecimal superMoney = sp.getPrepaymentAmount();
BigDecimal lackOfMoneyAsSuper = BigDecimal.ZERO;
if (allMoney.compareTo(superMoney) < 0) {
lackOfMoneyAsSuper = superMoney.subtract(allMoney);
}
result.put("all", allMoney.setScale(2).toString());
result.put("lackOfMoneyAsSuper", lackOfMoneyAsSuper.setScale(2).toString());
// 查配置、超级卖家门不能发布商品的金额
BigDecimal publishMinMoney = sp.getGoodsOnOffShelveAmount();
result.put("locked", sw.getLockAmount().setScale(2).toString());
result.put("avail", sw.getAmount().setScale(2).toString());
result.put("entryTime", (storedSeller == null || storedSeller.getEnterTime() < 1) ? ""
: sdf.format(1000L * storedSeller.getEnterTime()));
result.put("publishMoneyTip", publishMoneyTip + publishMinMoney.toString());
// TODO 查询用户权限状态
boolean logoGray = allMoney.compareTo(publishMinMoney) < 0;
result.put("logoGray", logoGray);
result.put("publishFunctionTip", publishFunctionTip);
// 查配置、超级卖家门不能发布商品的金额
BigDecimal canSaleMoney = sp.getHiddenGoodsAmount();
result.put("canSaleMoneyTip", canSaleMoneyTip + canSaleMoney.toString());
result.put("canSaleFunctionTip", canSaleFunctionTip);
result.put("recoverTip", recoverTip.replace("{}", lackOfMoneyAsSuper.toString()));
return new com.yohoufo.common.ApiResponse(200, "查询成功", result);
}
... ... @@ -388,9 +444,25 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
}
// 升级超级卖家:账号资金移动处理
public int changeWalletToSuperSeller(Integer uid) {
return sellerWalletMapper.changeAllMoneyToAvail(uid, DateUtil.getCurrentTimeSecond());
}
// *后期需要再次调用,清理残留
public int changeWalletToSuperSeller(Integer uid) {
logger.info("uid={}, 超级卖家:账号资金移动处理", uid);
// 使用钱包余额,支付保证金
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
logger.info("uid={}, 超级卖家:账号资金移动处理前账户={}", uid, sw);
if (sw == null) {
logger.error("超级卖家:账号资金移动处理失败,钱包不存在,uid={}", uid);
CommonAlarmEventPublisher.publish("超级卖家:账号资金移动处理失败", "ufo.order.changeWalletToSuperSeller", "钱包不存在,uid=" + uid);
return 0;
}
if (sw.getStatus() == null || sw.getStatus() == 0) {
CommonAlarmEventPublisher.publish("超级卖家:账号资金移动处理失败", "ufo.order.changeWalletToSuperSeller", "钱包不可用,uid=" + uid);
return 0;
}
int result = sellerWalletMapper.changeAllMoneyToAvail(uid, DateUtil.getCurrentTimeSecond());
logger.info("uid={}, 超级卖家:账号资金移动处理结果={}", uid, result);
return result;
}
// 支付保证金:总账修改
public SellerWallet useEarnest(Integer uid, BigDecimal money, MerchantOrderAttachInfo attach) {
... ... @@ -580,33 +652,33 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
private SellerWallet changeEarnest(Integer uid, BigDecimal money, long orderCode, MerchantOrderAttachInfo attach, SellerWalletDetail.Type type) {
BigDecimal money2 = money.setScale(2, BigDecimal.ROUND_HALF_UP);
if (money2.compareTo(money) != 0) {
logger.warn("{}修改钱包表入口,uid={},金额超出两位小数(自动截取) money={}, money2={}", type.getName(), uid, money, money2);
logger.warn("{}修改钱包表入口,orderCode={},uid={},金额超出两位小数(自动截取) money={}, money2={}", type.getName(), orderCode, uid, money, money2);
money = money2;
}
logger.info("{}修改钱包表入口,uid={},money={}", type.getName(), uid, money);
logger.info("{}修改钱包表入口,orderCode={},uid={},money={}", type.getName(), orderCode, orderCode, uid, money);
String message = type.getName();
// 使用钱包余额,支付保证金
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
logger.info("{}修改钱包表入口,uid={},钱包={}", type.getName(), uid, sw);
logger.info("{}修改钱包表入口,orderCode={},uid={},钱包={}", type.getName(), orderCode, uid, sw);
if (sw == null) {
logger.error(message + "失败,钱包不存在,uid={}", uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "钱包不存在uid=" + uid+", 金额为:"+money);
logger.error(message + "失败,钱包不存在,orderCode={},uid={}", orderCode, uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "钱包不存在,orderCode="+orderCode+",uid=" + uid+", 金额为:"+money);
return null;
}
if (sw.getStatus() == null || sw.getStatus() == 0) {
logger.error(message + "{}失败,钱包不可用,uid={}", money, uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "钱包不可用uid=" + uid+", 金额为:"+money);
logger.error(message + "{}失败,钱包不可用,orderCode={},uid={}", money, orderCode, uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "钱包不可用,orderCode="+orderCode+",uid=" + uid+", 金额为:"+money);
return null;
}
if ((type == SellerWalletDetail.Type.PUBLISH || type == SellerWalletDetail.Type.ADD_PRICE) && sw.getAmount().compareTo(money) < 0) {
logger.error(message + "{}失败,钱包余额不足,uid={}", money, uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "钱包余额不足uid=" + uid+", 金额为:"+money+", 账户余额为:"+sw.getAmount());
logger.error(message + "{}失败,钱包余额不足,orderCode={},uid={}", money, orderCode, uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "钱包余额不足,orderCode="+orderCode+",uid=" + uid+", 金额为:"+money+", 账户余额为:"+sw.getAmount());
return null;
}
BigDecimal beforeAvailAmount = sw.getAmount();
BigDecimal beforeLockAmount = sw.getLockAmount();
logger.info("{}修改钱包,uid={},金额计算后:beforeAvailAmount={}, beforeLockAmount={}", type.getName(), uid, beforeAvailAmount, beforeLockAmount);
logger.info("{}修改钱包,orderCode={},uid={},金额计算后:beforeAvailAmount={}, beforeLockAmount={}", type.getName(), orderCode, uid, beforeAvailAmount, beforeLockAmount);
BigDecimal availAmount = null;
BigDecimal lockAmount = null;
BigDecimal tradeAmount = null;
... ... @@ -618,7 +690,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
availAmount = money.multiply(new BigDecimal("-1"));
lockAmount = money;
tradeAmount = availAmount;
logger.info("{}修改钱包,uid={},减去保证金场合:", type.getName(), uid);
logger.info("{}修改钱包,orderCode={},uid={},减去保证金场合:", type.getName(), orderCode, uid);
} else if (type == SellerWalletDetail.Type.SELLER_OFF
|| type == SellerWalletDetail.Type.SYSTEM_OFF
|| type == SellerWalletDetail.Type.APPRAISE_OK
... ... @@ -628,7 +700,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
availAmount = money;
lockAmount = money.multiply(new BigDecimal("-1"));
tradeAmount = money;
logger.info("{}修改钱包,uid={},增加保证金场合:", type.getName(), uid);
logger.info("{}修改钱包,orderCode={},uid={},增加保证金场合:", type.getName(), orderCode, uid);
} else if (type == SellerWalletDetail.Type.SELLER_CANCEL
|| type == SellerWalletDetail.Type.SELLER_OVER_TIME
|| type == SellerWalletDetail.Type.APPRAISE_FAIL
... ... @@ -637,16 +709,16 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
// 如果是超级卖家
sellerType = sellerService.getEntrySellerType(uid);
boolean isSuper = (sellerType != null && sellerType == EntrySellerType.SUPER_ENTRY);
logger.info("{}修改钱包,uid={},处罚保证金场合:获取身份超级卖家:{}", type.getName(), uid, sellerType);
logger.info("{}修改钱包,orderCode={},uid={},处罚保证金场合:获取身份超级卖家:{}", type.getName(), orderCode, uid, sellerType);
if (isSuper) {
availAmount = money.multiply(new BigDecimal("-1"));
} else {
lockAmount = money.multiply(new BigDecimal("-1"));
}
tradeAmount = lockAmount;
logger.info("{}修改钱包,uid={},处罚保证金场合:", type.getName(), uid);
logger.info("{}修改钱包,orderCode={},uid={},处罚保证金场合:", type.getName(), orderCode, uid);
}
logger.info("{}修改钱包,uid={},金额计算后:availAmount={}, lockAmount={}, tradeAmount={}", type.getName(), uid, availAmount, lockAmount, tradeAmount);
logger.info("{}修改钱包,orderCode={},uid={},金额计算后:availAmount={}, lockAmount={}, tradeAmount={}", type.getName(), orderCode, uid, availAmount, lockAmount, tradeAmount);
sw.setAmount(availAmount);
sw.setLockAmount(lockAmount);
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
... ... @@ -674,8 +746,8 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
}
if(needLogErrAndReturn) {
logger.error(message + "失败,(余额不足或钱包不可用)更新表返回0,bean={}", sw);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.walletPunishment", "用户:" + uid + ",(余额不足货钱包不可用),更新表返回 0,bean为:"+ sw);
logger.error(message + "失败,(余额不足或钱包不可用)更新表返回0,orderCode={},bean={}", orderCode, sw);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.walletPunishment", "用户:" + uid + ",(余额不足货钱包不可用),更新表返回 0,orderCode="+orderCode+",bean为:"+ sw);
return null;
}
... ... @@ -698,7 +770,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
swd.setAttachValue(attach==null?"":JSON.toJSONString(attach));
swd.setAvailAmount(availAmount == null ? beforeAvailAmount : beforeAvailAmount.add(availAmount));
swd.setLockAmount(lockAmount == null ? beforeLockAmount : beforeLockAmount.add(lockAmount));
logger.info("{}修改钱包,uid={},明细availAmount={}, beforeAvailAmount={}, beforeLockAmount={}, lockAmount={}", type.getName(), uid, availAmount, beforeAvailAmount, beforeLockAmount, lockAmount);
logger.info("{}修改钱包,orderCode={},uid={},明细availAmount={}, beforeAvailAmount={}, beforeLockAmount={}, lockAmount={}", type.getName(), orderCode, uid, availAmount, beforeAvailAmount, beforeLockAmount, lockAmount);
swd.setIsSet(0);
/////////////////////////
logger.info("增加钱包明细汇总记录,bean={}", swd);
... ...
package com.yohoufo.order.service.handler;
/**
* Created by chao.chen on 2019/1/9.
*/
public class RefundEarnestMoneyHandler {
}
... ...
package com.yohoufo.order.service.handler;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.order.common.BillTradeStatus;
import com.yohoufo.order.common.RefundCase;
import com.yohoufo.order.convert.builder.AlarmEventBuilder;
import com.yohoufo.order.event.BillLogEvent;
import com.yohoufo.order.model.request.PaymentRequest;
import org.slf4j.Logger;
import java.math.BigDecimal;
import java.util.function.BiConsumer;
/**
* Created by chao.chen on 2019/1/9.
*/
public class RefundGoodsMoneyHandler {
private Integer uid;
private Long orderCode;
private Logger logger;
private BigDecimal goodsMoney;
private PaymentRequest paymentRequest;
private OrderStatus targetOrderStatus;
private BillLogEvent.BillLogEventBuilder bleb;
private BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> refundConsumer;
public RefundGoodsMoneyHandler loadTargetOrderStatus(OrderStatus targetOrderStatus){
this.targetOrderStatus = targetOrderStatus;
return this;
}
public RefundGoodsMoneyHandler loadLogger(Logger logger){
this.logger = logger;
return this;
}
public RefundGoodsMoneyHandler loadPaymentRequest(Integer uid,Long orderCode,BigDecimal goodsMoney){
this.uid = uid;
this.orderCode = orderCode;
this.goodsMoney = goodsMoney;
this.paymentRequest = PaymentRequest.builder().uid(uid)
.refundCase(RefundCase.BUYER_GOODS_MONEY)
.orderCode(orderCode).refundAmount(goodsMoney.doubleValue())
.build();
return this;
}
public RefundGoodsMoneyHandler loadRefundAction(BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> refundConsumer){
this.refundConsumer = refundConsumer;
return this;
}
public RefundGoodsMoneyHandler loadBillLogEventBuilder(BillLogEvent.BillLogEventBuilder bleb){
this.bleb = bleb;
return this;
}
public boolean refund(){
try {
refundConsumer.accept(paymentRequest, bleb);
return true;
}catch (Exception ex){
logger.warn("in refund goods money fail targetOrderStatus {} paymentRequest {} ", targetOrderStatus, paymentRequest);
BillLogEvent buyerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode()).build();
EventBusPublisher.publishEvent(buyerBillLogEvent);
SmsAlarmEvent smsAlarmEvent = AlarmEventBuilder.buildRefundBuyerGoodsMoneyAlarmEvent(targetOrderStatus, uid, orderCode);
EventBusPublisher.publishEvent(smsAlarmEvent);
return false;
}
}
}
... ...
... ... @@ -27,6 +27,7 @@ import com.yohoufo.order.service.IExpressInfoService;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.handler.RefundGoodsMoneyHandler;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
import com.yohoufo.order.utils.PaymentHelper;
... ... @@ -514,24 +515,30 @@ public class AppraiseService {
});
BigDecimal goodsMoney = buyerOrder.getAmount();
/*
PaymentRequest req = PaymentRequest.builder().uid(buyerUid)
.orderCode(orderCode).refundAmount(goodsMoney.doubleValue())
.build();
*/
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
.amount(goodsMoney)
.skup(skup);
boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler().loadPaymentRequest(buyerUid,orderCode,goodsMoney)
.loadBillLogEventBuilder(bleb)
.loadTargetOrderStatus(targetStatus)
.loadRefundAction(payRefundService::refund)
.loadLogger(LOGGER)
.refund();
if (!refundGoodsMoneyFlag){
apiResponse.setCode(400);
String content = "鉴定不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
apiResponse.setMessage(content);
}
/*
try{
payRefundService.refund(req, bleb);
//
//记录订单的状态变更信息
LOGGER.info("in appraiseFail record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetStatus.getCode());
//TODO 消息
inBoxFacade.noticeSellerWhenAppraiseFail( sellerOrderGoods,orderCode,wayBillCode);
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
}catch (Exception ex){
LOGGER.warn("in appraiseFail ,refund fail,req {}", req, ex);
BillLogEvent buyererBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
... ... @@ -542,15 +549,22 @@ public class AppraiseService {
AlarmConfig alarmConfig = AlarmConfig.APPRAISE_FAIL;
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getRefundName(), alarmConfig.name(), content);
EventBusPublisher.publishEvent(smsAlarmEvent);
}
*/
//记录订单的状态变更信息
LOGGER.info("in appraiseFail record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
try {
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
apiResponse.setCode(400);
apiResponse.setMessage(content);
//TODO 消息
inBoxFacade.noticeSellerWhenAppraiseFail(sellerOrderGoods, orderCode, wayBillCode);
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
}catch(Exception ex) {
LOGGER.warn("in appraiseFail orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
}finally {
//更新物流信息,写到最后
//鉴定不通过,不发物流
//expressInfoService.appraiseFail(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
//记录调拨信息(只保存卖家一条)
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
... ... @@ -562,12 +576,9 @@ public class AppraiseService {
}else{
LOGGER.warn("in appraiseFail, buyer Order now status {}, expect expectStatus {}",
buyerOrder.getStatus(), expectStatus);
apiResponse.setCode(400);
apiResponse.setMessage("订单状态发生变化");
}
return apiResponse;
}
}
... ...
... ... @@ -25,6 +25,7 @@ import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.concurrent.ThreadPoolFactory;
import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
import com.yohoufo.order.service.handler.RefundGoodsMoneyHandler;
import com.yohoufo.order.service.proxy.CouponProxyService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
... ... @@ -94,11 +95,11 @@ public class BuyerOrderCancelService {
int buyerUid = bsdEvent.getBuyerUid();
int sellerUid = bsdEvent.getSellerUid();
long orderCode = bsdEvent.getOrderCode();
OrderStatus target = bsdEvent.getTarget();
OrderStatus targetOrderStatus = bsdEvent.getTarget();
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
logger.info("in buyer cancel BeforeSellerDeliver begin buyerOrderMapper.selectByOrderCode, buyerUid {}, orderCode {}, skup {} buyerOrder {}",
buyerUid, orderCode, buyerOrder );
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, target);
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus);
logger.info("in buyer cancel BeforeSellerDeliver, event {} BuyerPenaltyCalResult {}", bsdEvent, bpcr);
//买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
if(bsdEvent.getAmount()==null||bsdEvent.getAmount().compareTo(bpcr.getPenaltyAmount()) < 0){
... ... @@ -109,7 +110,7 @@ public class BuyerOrderCancelService {
OrderStatus expected = bsdEvent.getExpected();
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), target.getCode(), currentTime);
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
if (rows>0) {
//退还优惠券
refundCouponIfNeed(buyerUid, orderCode);
... ... @@ -134,6 +135,7 @@ public class BuyerOrderCancelService {
//(退费)扣除赔偿款,计算剩余的货款,退给买家
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerOrder, skup,
bpcr, transferCase);
bcapt.targetOrderStatus = targetOrderStatus;
bcapt.setSwdType(SellerWalletDetail.Type.BUYER_CANCEL_NO_DELIVERY);
Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
... ... @@ -195,11 +197,11 @@ public class BuyerOrderCancelService {
int buyerUid = bdrEvent.getBuyerUid();
int sellerUid = bdrEvent.getSellerUid();
long orderCode = bdrEvent.getOrderCode();
OrderStatus target = bdrEvent.getTarget();
OrderStatus targetOrderStatus = bdrEvent.getTarget();
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
logger.info("in buyer cancel BeforeDepotReceive begin buyerOrderMapper.selectByOrderCode, buyerUid {}, orderCode {}, skup {} buyerOrder {}",
buyerUid, orderCode, buyerOrder );
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, target);
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus);
logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, bpcr);
//买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
if(bdrEvent.getAmount()==null||bdrEvent.getAmount().compareTo(bpcr.getPenaltyAmount()) < 0){
... ... @@ -210,7 +212,7 @@ public class BuyerOrderCancelService {
OrderStatus expected = bdrEvent.getExpected();
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), target.getCode(), currentTime);
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
if (rows>0) {
//退还优惠券
refundCouponIfNeed(buyerUid, orderCode);
... ... @@ -236,6 +238,7 @@ public class BuyerOrderCancelService {
TransferCase transferCase = TransferCase.PART_GOODS_MONEY_TO_SELLER;
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerOrder, skup,
bpcr, transferCase);
bcapt.targetOrderStatus = targetOrderStatus;
bcapt.setSwdType(SellerWalletDetail.Type.BUYER_CANCEL_DELIVERY);
Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
... ... @@ -261,6 +264,7 @@ public class BuyerOrderCancelService {
BuyerPenaltyCalResult bpcr;
BuyerOrder buyerOrder;
TransferCase transferCase;
OrderStatus targetOrderStatus;
@Setter
SellerWalletDetail.Type swdType;
... ... @@ -331,16 +335,26 @@ public class BuyerOrderCancelService {
void refundLeftOrderAmount(BuyerPenaltyCalResult bpcr, BuyerOrder buyerOrder){
Integer sellerUid = buyerOrder.getSellerUid();
BigDecimal leftBuyerMoney = bpcr.getLeftAmount();
/*
PaymentRequest rprOfBuyer = PaymentRequest.builder().uid(buyerUid)
.orderCode(orderCode).refundAmount(leftBuyerMoney.doubleValue())
.build();
*/
BillLogEvent.BillLogEventBuilder blebOfBuyer = BillLogEvent.builder()
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
.amount(leftBuyerMoney)
.skup(skup);
logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, rprOfBuyer );
logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
buyerUid, orderCode, skup, leftBuyerMoney );
new RefundGoodsMoneyHandler().loadLogger(logger)
.loadPaymentRequest(buyerUid,orderCode,leftBuyerMoney)
.loadBillLogEventBuilder(blebOfBuyer)
.loadRefundAction(payRefundService::refund)
.loadTargetOrderStatus(targetOrderStatus)
.refund();
/*
try {
payRefundService.refund(rprOfBuyer, blebOfBuyer);
}catch (Exception ex){
... ... @@ -349,9 +363,9 @@ public class BuyerOrderCancelService {
String content = "用户" + buyerUid + "订单"+ orderCode +"退货款失败";
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("buyerPaidOrder.selfCancel", "cancel", content);
EventBusPublisher.publishEvent(smsAlarmEvent);
}
logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
buyerUid, orderCode, skup, rprOfBuyer );
}*/
logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
buyerUid, orderCode, skup, leftBuyerMoney );
}
@Override
... ...
... ... @@ -27,6 +27,7 @@ import com.yohoufo.order.mq.producer.TradeMqSender;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.handler.RefundGoodsMoneyHandler;
import com.yohoufo.order.service.impl.visitor.AutoCancelCase;
import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase;
import com.yohoufo.order.service.impl.visitor.UserCancelCase;
... ... @@ -435,11 +436,8 @@ public class SellerOrderCancelService {
result += buyerOrderMapper.updateStatusByOrderCode(buyerOrderCode, buyerUid, buyerOrderStatus,
targetBOStatus.getCode(), currentDT);
if(result > 0) {
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder()
.bizCase(BuyerRefundCouponEvent.BizCase.SELLER_PLAY_BUYER)
.uid(buyerUid)
.orderCode(buyerOrderCode)
.build();
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.SELLER_PLAY_BUYER)
.uid(buyerUid).orderCode(buyerOrderCode).build();
EventBusPublisher.publishEvent(brce);
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(sellerOrder.getSkup());
... ... @@ -465,31 +463,38 @@ public class SellerOrderCancelService {
result += sellerOrderMapper.updateByOrderCode(target);
BigDecimal goodsMoney = buyerOrder.getAmount();
/*
PaymentRequest refundReq = PaymentRequest.builder().uid(buyerUid)
.orderCode(buyerOrderCode).refundCase(RefundCase.BUYER_GOODS_MONEY)
.refundAmount(goodsMoney.doubleValue())
.build();
*/
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(buyerOrderCode)
.payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
.amount(goodsMoney)
.skup(sellerOrder.getSkup());
//分赃(分账) 有待考虑使用2比对
TransferCase transferCase = TransferCase.EARNEST_MONEY_TO_BUYER;
TransferMoneyRequest tmReq = TransferMoneyRequest.builder()
.buyerOrderCode(buyerOrderCode)
.type(transferCase.getCode())
.transferCase(transferCase)
.swdType(SellerWalletDetail.Type.SELLER_CANCEL)
.alarmConfig(AlarmConfig.SELLER_PLAY_BUYER)
.build();
transferService.transfer(tmReq);
new RefundGoodsMoneyHandler().loadLogger(logger)
.loadTargetOrderStatus(targetBOStatus)
.loadRefundAction(payRefundService::refund)
.loadBillLogEventBuilder(bleb)
.loadPaymentRequest(buyerUid,buyerOrderCode,goodsMoney)
.refund();
/*
try{
//分赃(分账) 有待考虑使用2比对
TransferCase transferCase = TransferCase.EARNEST_MONEY_TO_BUYER;
TransferMoneyRequest tmReq = TransferMoneyRequest.builder()
.buyerOrderCode(buyerOrderCode)
.type(transferCase.getCode())
.transferCase(transferCase)
.swdType(SellerWalletDetail.Type.SELLER_CANCEL)
.alarmConfig(AlarmConfig.SELLER_PLAY_BUYER)
.build();
transferService.transfer(tmReq);
PayRefundBo refundResp = payRefundService.refund(refundReq, bleb);
//异步
inBoxFacade.noticeBuyerWhenSellerCancelAfterPaid(buyerUid, buyerOrderCode, psog.getProductName());
inBoxFacade.sellerCancelAfterBuyerPaid( psog);
}catch (Exception ex){
logger.warn("in cancelAfterPayExistBuyAction , refund fail,req {}", refundReq, ex);
BillLogEvent buyererBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
... ... @@ -499,7 +504,10 @@ public class SellerOrderCancelService {
AlarmConfig alarmConfig = AlarmConfig.SELLER_PLAY_BUYER;
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getRefundName(), alarmConfig.name(), content);
EventBusPublisher.publishEvent(smsAlarmEvent);
}
}*/
//异步
inBoxFacade.noticeBuyerWhenSellerCancelAfterPaid(buyerUid, buyerOrderCode, psog.getProductName());
inBoxFacade.sellerCancelAfterBuyerPaid( psog);
//记录状态信息
logger.info("in cancelAfterPayExistBuyAction record status change, orderCode {}", buyerOrderCode);
... ...
... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.resp.EntryThreshold;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.StoredSellerMapper;
import com.yohoufo.dal.order.SuperEntrySellerMapper;
... ... @@ -18,7 +19,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
... ... @@ -147,4 +150,52 @@ public class SellerService {
return est;
}
/**
* 申请成为超级卖家
* 对于未支付的某一种身份申请做订单号替换
* @param uid
* @param orderCode
*/
public void applySuperEntry(Integer uid, Long orderCode, EntrySellerType targetEST){
}
/**
* 支付成功后回调
* (一)用于处理卖家申请,
* 1. 成为普通入驻 (晋升 普通卖家->普通入驻)
* 2. 成为超级入驻
* 2.1: 普通卖家 -> 超级入驻 ;
* 2.2 :普通入驻 -> 超级入驻;
* (二)普通卖家充值,丢弃;
* (三)超级卖家
* 1. 如果取消能力 -> 恢复;
* 2. 没有取消,丢弃;
*
* @param uid
* @param orderCode
*/
public void processApply(Integer uid, Long orderCode, BigDecimal total){
}
public Map<EntrySellerType,EntryThreshold> getEntryThreshold(){
Map<EntrySellerType,EntryThreshold> map = new HashMap<>(2);
EntryThreshold commonET = new EntryThreshold();
commonET.setEntrySellerType(EntrySellerType.COMMON);
commonET.setPrepaymentAmount(new BigDecimal(999));
map.put(commonET.getEntrySellerType(), commonET);
EntryThreshold superET = new EntryThreshold();
superET.setEntrySellerType(EntrySellerType.SUPER_ENTRY);
superET.setPrepaymentAmount(new BigDecimal(5000));
superET.setGoodsOnOffShelveAmount(new BigDecimal(3000));
superET.setHiddenGoodsAmount(new BigDecimal(1000));
map.put(superET.getEntrySellerType(), superET);
return map;
}
}
... ...
... ... @@ -4,6 +4,7 @@ import com.yoho.error.exception.ServiceException;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.resp.SellerResp;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.dal.order.StoredSellerMapper;
import com.yohoufo.dal.order.model.StoredSeller;
... ... @@ -21,6 +22,7 @@ import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Service
public class StoreSellerServiceImpl implements IStoredSellerService {
... ... @@ -42,6 +44,9 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
@Value("${zhimacert.switch:true}")
private boolean zhiMaCertSwitch;
@Autowired
private SellerService sellerService;
/**
* 是否入驻商户
* @param uid
... ... @@ -58,7 +63,7 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
}
@Override
public Map<String,Boolean> entryStatus(Integer uid){
public SellerResp entryStatus(Integer uid){
logger.info("StoredSellerServiceImpl entryStatus uid is {} ",uid);
Boolean isZhiMaCert=false;
... ... @@ -92,11 +97,14 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
}
}
Map<String,Boolean> map=new HashMap<>();
map.put("isZhiMaCert",isZhiMaCert);
map.put("isStoredSeller",isStoredSeller);
map.put("storedBefore",storedBefore);
return map;
EntrySellerType entrySellerType = sellerService.getEntrySellerType(uid);
SellerResp sellerResp = new SellerResp();
sellerResp.setZhiMaCert(isZhiMaCert);
sellerResp.setStoredBefore(storedBefore);
sellerResp.setStoredSeller(isStoredSeller);
if(Objects.nonNull(entrySellerType))
sellerResp.setEntrySellerType(entrySellerType.getCode());
return sellerResp;
}
@Override
... ...
... ... @@ -6,6 +6,7 @@ import com.yoho.error.exception.ServiceException;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
import com.yohobuy.ufo.model.order.common.EntrySellerDepositType;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
... ... @@ -73,6 +74,9 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi
@Autowired
private SkupService skupService;
@Autowired
private SellerService sellerService;
/**
* 充值保证金
... ... @@ -118,6 +122,10 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi
int num = entrySellerRechargeOrderMapper.insert(entrySellerRechargeOrder);
logger.info("enter StoredSellerDepositServiceImpl depositRecharge end save entrySellerRechargeOrder {} ,num {}",entrySellerRechargeOrder,num);
if (shoppingRequest.getAsSuper() == 1) {
markAsSuper(orderCode, uid, EntrySellerType.SUPER_ENTRY);
}
// 返回结果
return OrderSubmitResponse.builder().orderCode(orderCode).paymentStatus(OrderConstant.N_STR).build();
... ... @@ -175,12 +183,22 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi
int num = entrySellerRechargeOrderMapper.insert(entrySellerRechargeOrder);
logger.info("enter StoredSellerDepositServiceImpl depositPreStore end save entrySellerRechargeOrder {} ,num {}",entrySellerRechargeOrder,num);
if (shoppingRequest.getAsSuper() == 1) {
markAsSuper(orderCode, uid, EntrySellerType.SUPER_ENTRY);
} else {
markAsSuper(orderCode, uid, EntrySellerType.COMMON);
}
// 返回结果
return OrderSubmitResponse.builder().orderCode(orderCode).paymentStatus(OrderConstant.N_STR).build();
}
/**
private void markAsSuper(long orderCode, Integer uid, EntrySellerType sellerType) {
sellerService.applySuperEntry(uid, orderCode, sellerType);
}
/**
* 退出入驻
* @param uid
*/
... ...
package com.yohoufo.order.utils;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderStatus;
public class BuyerOrderUtils {
/**
* 订单状态是否已完成
*/
public static boolean isOrderDone(int status) {
return status == OrderStatus.DONE.getCode();
}
/**
* 订单状态是否已完成
*/
public static boolean isOrderDone(OrderInfo orderInfo) {
if(orderInfo == null)
return false;
return isOrderDone(orderInfo.getStatus());
}
/**
* 是否门店订单
*/
public static boolean isOffline(Integer attributes) {
if(OrderAttributes.getOrderAttributes(attributes) == OrderAttributes.OFFLINE)
return true;
return false;
}
/**
* 是否门店订单
*/
public static boolean isOffline(OrderInfo orderInfo) {
if(orderInfo == null)
return false;
return isOffline(orderInfo.getAttributes());
}
}
... ...
... ... @@ -12,6 +12,8 @@ import com.yohoufo.dal.product.model.Storage;
import com.yohoufo.product.helper.TrendTypeEnum;
import com.yohoufo.product.model.PriceTrendResp;
import com.yohoufo.product.service.impl.pricetrend.PriceTrendServiceInf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
... ... @@ -29,6 +31,8 @@ import java.util.stream.Collectors;
*/
@Service
public class ProductPriceService implements ApplicationContextAware{
private final Logger LOG = LoggerFactory.getLogger(ProductPriceService.class);
private Map<String, PriceTrendServiceInf> beansOfType;
@Autowired
... ... @@ -41,20 +45,23 @@ public class ProductPriceService implements ApplicationContextAware{
String beanNameByCode = TrendTypeEnum.getBeanNameByCode(trendType);
if (null == beanNameByCode) {
LOG.error("method queryProductPriceTrend error, product_id={}, size_id is {}, trend_type is {}", productId, sizeId, trendType);
return Lists.newArrayList();
}
List<PriceTrendModel> priceTrendModels = beansOfType.get(beanNameByCode).queryProductPriceTrend(productId, sizeId);
LOG.info("priceTrendModels result is {}", priceTrendModels.size());
List<PriceTrendResp> result = Lists.newArrayList();
priceTrendModels.stream().forEach(item -> {
priceTrendModels.stream().forEach(item ->
result.add(new PriceTrendResp.Builder().setProductId(item.getProductId())
.setSizeId(item.getSizeId())
.setSknPrice(item.getSknPrice())
.setSkuPrice(item.getSkuPrice())
.setCreateTime(DateUtil.getDateFormatEx(item.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS))
.build());
});
.build())
);
return result;
}
... ...
... ... @@ -123,18 +123,20 @@ public class ProductSearchServiceImpl implements ProductSearchService {
public JSONObject searchProductList(ProductSearchReq req) {
SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
// type:0,推荐;1,热销;
// 2,即将发售;
// 2,即将发售; *
// 3,品类; 4,品牌;5,系列;
// 6,搜索
// 7, 收藏
String url = PRODUCT_LIST_URL;
if(StringUtils.equals("Y", req.getIsSoonSale())) {
url = SOON_SALE_PRODUCT_LIST_URL;
} else if(StringUtils.equals("Y", req.getIsIdFilter())) {
url = FAVORITE_PRODUCT_LIST_URL;
} else if (req.getSearchType() == 6) {
// 7, 收藏 *
String url = PRODUCT_LIST_URL;
if (StringUtils.equals("Y", req.getIsSoonSale())) {
url = SOON_SALE_PRODUCT_LIST_URL;
} else if (StringUtils.equals("Y", req.getIsIdFilter())) {
url = FAVORITE_PRODUCT_LIST_URL;
} else if (StringUtils.isNotBlank(req.getQuery())
|| (req.getSearchType() != null && req.getSearchType() == 6)) {
url = PRODUCT_SEARCH_QUERY_URL;
} else if (req.getSearchType() == 0 || req.getSearchType() == 1) {
} else if (StringUtils.isNotBlank(req.getPool())
|| (req.getSearchType() != null && (req.getSearchType() == 0 || req.getSearchType() == 1))) {
url = PRODUCT_POOL_URL;
}
JSONObject data = search(searchParam.getParam(), url);
... ...
... ... @@ -664,7 +664,8 @@ public class ProductServiceImpl implements ProductService{
}
goodsSize.setLeastPrice(storagePrice == null ? null : storagePrice.getPrice());
goodsSize.setStatus(storagePrice == null ? null : storagePrice.getStatus());
goodsSize.setStorageNum(storagePrice == null ? 0 : storage.getStorageNum());
//goodsSize.setStorageNum(storagePrice == null ? 0 : storage.getStorageNum());
goodsSize.setStorageNum(goodsSize.getSkup() == null || goodsSize.getSkup() == 0 ? 0 : 1);
goodsSize.setSkup(storagePrice == null ? 0 : storagePrice.getSkup());
}
}
... ...
... ... @@ -5,6 +5,8 @@ import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.product.PriceTrendDayMapper;
import com.yohoufo.dal.product.model.PriceTrendModel;
import com.yohoufo.product.model.PriceTrendResp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -15,12 +17,19 @@ import java.util.List;
*/
@Service(value = "PriceTrendDayService")
public class PriceTrendDayService implements PriceTrendServiceInf{
private final Logger LOG = LoggerFactory.getLogger(PriceTrendDayService.class);
@Autowired
private PriceTrendDayMapper priceTrendDayMapper;
public List<PriceTrendModel> queryProductPriceTrend(Integer productId, Integer sizeId) {
if (null != productId) {
return priceTrendDayMapper.selectByProductId(productId, sizeId, DateUtil.getTimeSecondOfDay(0), DateUtil.getTimeSecondOfDay(1));
int currentSecond = DateUtil.getTimeSecondOfDay(0);
int tomorrowSecond = DateUtil.getTimeSecondOfDay(1);
LOG.info("method priceTrendDayMapper.selectByProductId in, productId:{},sizeId:{},currentSecond:{},tomorrowSecond:{}", productId, sizeId, currentSecond, tomorrowSecond);
return priceTrendDayMapper.selectByProductId(productId, sizeId, currentSecond, tomorrowSecond);
}
return Lists.newArrayList();
... ...
... ... @@ -106,6 +106,12 @@ order.buyer.cancelWhenSellerUnDelivery.money=38
order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate=0.8
order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate=0.8
order.seller.tip.publishMoneyTip=\u4FDD\u8BC1\u91D1\u4F59\u989D\u4E0D\u8DB3
order.seller.tip.publishFunctionTip=\u8BF7\u5145\u503C\u540E\u8FDB\u884C\u6B63\u5E38\u4E0A\u67B6/\u4E0B\u67B6
order.seller.tip.canSaleMoneyTip=\u4FDD\u8BC1\u91D1\u4F59\u989D\u4F4E\u4E8E
order.seller.tip.canSaleFunctionTip=\u5E73\u53F0\u4E0B\u67B6\u60A8\u6240\u6709\u51FA\u552E\u4E2D\u7684\u5546\u54C1
order.seller.tip.recoverTip=\u5145\u503C \uFFE5{} \u6062\u590D\u8D85\u7EA7\u5546\u5BB6\u6743\u9650
uic.url=http://java-yoho-uic.test3.ingress.dev.yohocorp.com/uic
... ...
... ... @@ -79,6 +79,13 @@ order.buyer.cancelWhenSellerUnDelivery.money=${order.buyer.cancelWhenSellerUnDel
order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate=${order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate}
order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate=${order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate}
order.seller.tip.publishMoneyTip=${order.seller.tip.publishMoneyTip}
order.seller.tip.publishFunctionTip=${order.seller.tip.publishFunctionTip}
order.seller.tip.canSaleMoneyTip=${order.seller.tip.canSaleMoneyTip}
order.seller.tip.canSaleFunctionTip=${order.seller.tip.canSaleFunctionTip}
order.seller.tip.recoverTip=${order.seller.tip.recoverTip}
erp-gateway.url=${erp-gateway.url}
uic.url=${uic.url}
... ...