Authored by chenchao

Merge branch 'master' into dev_order

Showing 23 changed files with 215 additions and 70 deletions
... ... @@ -219,7 +219,7 @@ public class ControllerCacheAop implements ApplicationContextAware{
methodParams.add(param);
}
String arg_sign = String.join("-", methodParams).replaceAll("\\s+","");
String arg_sign = String.join("-", methodParams).replaceAll("\\s+","-");
return arg_sign;
}
... ... @@ -253,4 +253,5 @@ public class ControllerCacheAop implements ApplicationContextAware{
throws BeansException {
this.applicationContext=applicationContext;
}
}
... ...
... ... @@ -53,8 +53,8 @@ public class AddressUtil {
public static void main(String[] args){
int result = AddressUtil.getDecryptStr("YR5uNKQ+Cd8z0Nu4+hHr0g==");
System.out.println(result);
String hidden = "i4cTBWa4QCq4x97BWgcuvw==";
int result = AddressUtil.getDecryptStr(hidden);
System.out.println(hidden + "-->" + result);
}
}
... ...
package com.yohoufo.common.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
public class IpUtils {
private static final Logger log = LoggerFactory.getLogger(IpUtils.class);
public static String getHostIp() {
String ip = null;
try {
Enumeration<NetworkInterface> en = NetworkInterface
.getNetworkInterfaces();
while (en.hasMoreElements()) {
NetworkInterface intf = (NetworkInterface) en.nextElement();
Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses();
while (enumIpAddr.hasMoreElements()) {
InetAddress inetAddress = (InetAddress) enumIpAddr
.nextElement();
if (!inetAddress.isLoopbackAddress()
&& !inetAddress.isLinkLocalAddress()
&& inetAddress.isSiteLocalAddress()) {
ip = inetAddress.getHostAddress();
}
}
}
} catch (SocketException e) {
log.error("Fail to get IP address.", e);
}
return ip;
}
public static String getHostName() {
String hostName = null;
try {
Enumeration<NetworkInterface> en = NetworkInterface
.getNetworkInterfaces();
while (en.hasMoreElements()) {
NetworkInterface intf = (NetworkInterface) en.nextElement();
Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses();
while (enumIpAddr.hasMoreElements()) {
InetAddress inetAddress = (InetAddress) enumIpAddr
.nextElement();
if (!inetAddress.isLoopbackAddress()
&& !inetAddress.isLinkLocalAddress()
&& inetAddress.isSiteLocalAddress()) {
hostName = inetAddress.getHostName();
}
}
}
} catch (SocketException e) {
log.error("Fail to get host name.", e);
}
return hostName;
}
}
... ...
... ... @@ -67,7 +67,6 @@
from buyer_order
where order_code = #{orderCode,jdbcType=BIGINT}
and uid = #{uid,jdbcType=INTEGER}
and buyer_order_status = 1
limit 1
</select>
... ...
package com.yohoufo.order.convert;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.response.GoodsInfo;
/**
* Created by chao.chen on 2018/11/2.
*/
public class GoodsInfoConvertor {
public static GoodsInfo SellerOrderGoods2GoodsInfo(SellerOrderGoods sellerOrderGoods) {
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.setSkup(sellerOrderGoods.getId());
goodsInfo.setProductName(sellerOrderGoods.getProductName());
goodsInfo.setColorName(sellerOrderGoods.getColorName());
goodsInfo.setSizeName(sellerOrderGoods.getSizeName());
goodsInfo.setGoodImg(ImageUrlAssist.getAllProductPicUrl(sellerOrderGoods.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
goodsInfo.setGoodPrice(sellerOrderGoods.getGoodsPrice().toPlainString());
goodsInfo.setProductId(sellerOrderGoods.getProductId());
goodsInfo.setStorageId(sellerOrderGoods.getStorageId());
return goodsInfo;
}
}
... ...
... ... @@ -50,6 +50,10 @@ public class NotPaidNoticeDelayMsgConsumer implements YhConsumer {
case BUY:
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(event.getOrderCode(), event.getUid());
if (Objects.isNull(buyerOrder)){
logger.info("in {}, msg {}, buyerOrder is delete", topic, event);
return;
}
if(OrderStatus.WAITING_PAY.getCode() == buyerOrder.getStatus()){
logger.info("in {}, msg {}, status {}", topic, event, buyerOrder.getStatus());
inBoxFacade.buyerOrderNotPayed(event.getUid(), event.getOrderCode());
... ...
... ... @@ -13,6 +13,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.order.common.Payment;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.model.AddressInfo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohoufo.order.model.request.OrderRequest;
... ... @@ -72,7 +73,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{
// 查询订单状态
BuyerOrder buyerOrder = getBuyerOrder(uid, orderCode);
if (buyerOrder == null){
logger.warn("getOrderDetail orderCode exist, uid is {}, orderCode is {}",
logger.warn("getOrderDetail order not exist, uid is {}, orderCode is {}",
uid, orderCode );
throw new ServiceException(ServiceError.ORDER_NULL);
}
... ... @@ -177,15 +178,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{
* @return
*/
private GoodsInfo getGoodsInfo(SellerOrderGoods sellerOrderGoods) {
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.setProductName(sellerOrderGoods.getProductName());
goodsInfo.setColorName(sellerOrderGoods.getColorName());
goodsInfo.setSizeName(sellerOrderGoods.getSizeName());
goodsInfo.setGoodImg(ImageUrlAssist.getAllProductPicUrl(sellerOrderGoods.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
goodsInfo.setGoodPrice(sellerOrderGoods.getGoodsPrice().toPlainString());
goodsInfo.setProductId(sellerOrderGoods.getProductId());
goodsInfo.setStorageId(sellerOrderGoods.getStorageId());
return goodsInfo;
return GoodsInfoConvertor.SellerOrderGoods2GoodsInfo(sellerOrderGoods);
}
... ...
... ... @@ -2,6 +2,8 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
... ... @@ -16,9 +18,6 @@ import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.common.DelStatus;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohoufo.order.model.AddressInfo;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
... ... @@ -29,7 +28,6 @@ import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.utils.SmsHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -69,8 +67,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
private InBoxFacade inBoxFacade;
@Autowired
private SellerAddressService sellerAddressService;
@Autowired
private OrderCacheService orderCacheService;
... ... @@ -285,7 +281,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid);
if (Objects.isNull(buyerOrder)){
if (Objects.isNull(buyerOrder) || buyerOrder.getBuyerOrderStatus() == DelStatus.IS_DEL.getCode()){
logger.warn("buyer delete, order not exist, uid {}, orderCode {}", uid, orderCode);
return false;
}
... ...
... ... @@ -690,6 +690,10 @@ public class PaymentServiceImpl implements IPaymentService {
preSuccess.setDealStatus(1);
preSuccess.setDealUid(req.getOperateUid());
preSuccess.setDealUserName(req.getOperateUname());
tradeBills.setDealUid(req.getOperateUid());
tradeBills.setDealUserName(req.getOperateUname());
if (tradeBillsMapper.updateToOkByPrimaryKey(preSuccess) == 0) {
throw new ServiceException(400, "manualDeal:流水已经处理过id=" + tradeBills.getId());
}
... ...
... ... @@ -83,7 +83,6 @@ public class SellerFeeService {
*/
public BigDecimal computeBuyerCompensate(int skup){
logger.info("in compute Buyer Compensate skup {}", skup);
long orderCode;
if(skup <= 0){
return null;
}
... ... @@ -97,7 +96,7 @@ public class SellerFeeService {
ServiceFeeRate serviceFeeRate = computeResult.getServiceFeeRate();
EarnestMoney earnestMoney = computeResult.getEarnestMoney();
BigDecimal compensate = earnestMoney.getEarnestMoney().subtract(earnestMoney.getEarnestMoney().multiply(serviceFeeRate.getEarnestMoneyRate()));
return compensate;
return compensate.setScale(2,BigDecimal.ROUND_HALF_UP);
} catch (Exception ex){
logger.warn("in computeCompensate by skup {} occur error", skup, ex);
return null;
... ...
... ... @@ -17,6 +17,7 @@ import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.*;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.AddressInfo;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
... ... @@ -232,16 +233,7 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
* @return
*/
private GoodsInfo getGoodsInfo(SellerOrderGoods sellerOrderGoods) {
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.setSkup(sellerOrderGoods.getId());
goodsInfo.setProductName(sellerOrderGoods.getProductName());
goodsInfo.setColorName(sellerOrderGoods.getColorName());
goodsInfo.setSizeName(sellerOrderGoods.getSizeName());
goodsInfo.setGoodImg(ImageUrlAssist.getAllProductPicUrl(sellerOrderGoods.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
goodsInfo.setGoodPrice(sellerOrderGoods.getGoodsPrice().toPlainString());
goodsInfo.setProductId(sellerOrderGoods.getProductId());
goodsInfo.setStorageId(sellerOrderGoods.getStorageId());
return goodsInfo;
return GoodsInfoConvertor.SellerOrderGoods2GoodsInfo(sellerOrderGoods);
}
/**
... ...
... ... @@ -378,7 +378,7 @@ public class InBoxFacade {
/**
* 交易关闭:订单生成,买家取消订单(主动 超时未支付时)
*
* 去掉短信发送 modify by craig.qin 20181013
* @param sellerUid
* @param prdName
*/
... ... @@ -394,6 +394,7 @@ public class InBoxFacade {
sellerUid, prdName, resp);
//短信
/**
String phone = userProxyService.getMobile(sellerUid);
if (StringUtils.isBlank(phone)){
logger.warn("noticSellerWhenBuyerCancel sms send fail,sellerUid {}, prdName {}", sellerUid, prdName);
... ... @@ -405,6 +406,7 @@ public class InBoxFacade {
sendSmsService.smsSendByMobile(content, mobileList);
logger.info("record noticSellerWhenBuyerCancel sms inbox msg, sellerUid {}, prdName {}, resp {}",
sellerUid, prdName);
*/
});
} catch (Exception e) {
... ...
... ... @@ -29,7 +29,7 @@ public class SendSmsService {
private String messageUrl;
public void smsSendByMobile(String content, List<String> mobileList) {
log.info("smsSendByMobile start.");
log.info("smsSendByMobile start, content {}, mobileList {}", content, mobileList);
if(StringUtils.isEmpty(content) || CollectionUtils.isEmpty(mobileList)) {
log.warn("smsSendByMobile fail! content is null or mobileList is empty");
return;
... ...
... ... @@ -6,9 +6,12 @@ import com.yohoufo.order.service.support.codegenerator.bean.CodeBitMeta;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import com.yohoufo.order.service.support.codegenerator.converter.IdConverterHelper;
import com.yohoufo.order.service.support.codegenerator.populater.AtomicIdPopulator;
import com.yohoufo.order.service.support.codegenerator.populater.MachineIdProvider;
import com.yohoufo.order.service.support.codegenerator.populater.PropMachineIdProvider;
import com.yohoufo.order.service.support.codegenerator.timer.SimpleTimer;
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.Component;
... ... @@ -25,11 +28,10 @@ public class OrderCodeGeneratorImpl implements OrderCodeGenerator {
AtomicIdPopulator idPopulator;
/**
* 机器节点: 取值0-7
*/
@Value("${env.machineId:0}")
private long machineId;
@Autowired
MachineIdProvider machineIdProvider;
long machineId = 0l;
@PostConstruct
public void init() {
... ... @@ -42,6 +44,8 @@ public class OrderCodeGeneratorImpl implements OrderCodeGenerator {
idPopulator = new AtomicIdPopulator();
}
machineId = machineIdProvider.getMachineId();
// 3位 0~8
validateMachineId(this.machineId);
}
... ...
package com.yohoufo.order.service.support.codegenerator.populater;
public interface MachineIdProvider {
public long getMachineId();
}
... ...
package com.yohoufo.order.service.support.codegenerator.populater;
import com.yohoufo.common.utils.IpUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
@Component
public class PropMachineIdProvider implements MachineIdProvider {
protected final Logger log = LoggerFactory.getLogger(this.getClass());
private Map<String, Long> ipsMap = new HashMap<String, Long>();
@Value("${ips.machine}")
private String machineIps;
@Override
public long getMachineId() {
String ip = IpUtils.getHostIp();
log.info("ip:{}, machineIps is {}",ip, machineIps);
Long machineId = ipsMap.get(ip);
if (machineId == null){
return 0l;
}
return machineId.longValue();
}
@PostConstruct
public void init(){
if (StringUtils.isEmpty(machineIps)) {
return;
}
String[] ips = machineIps.split(",");
for (int i=0; i < ips.length; i++){
ipsMap.put(ips[i], (long)i);
}
}
}
... ...
... ... @@ -76,6 +76,8 @@ public class SearchParam {
}
if (StringUtils.isNotEmpty(orderVal)) {
param.put(SearchConstants.IndexNameConstant.ORDER, orderVal);
} else {
param.put(SearchConstants.IndexNameConstant.ORDER, order);
}
}
return this;
... ...
... ... @@ -52,16 +52,19 @@ public class FavoriteController {
vo.setLimit(20);
}
int total = favoriteService.numFavorite(vo);
int pageSize = vo.getLimit();
int frontPage = vo.getPage();
//分页获取收藏的商品id,
List<String> productIds= favoriteService.listFavorite(vo);
logger.info("After call ufo.user.favoriteList result productIds is {}", productIds);
if(productIds==null||productIds.size()<=0){
if(total<=0||productIds==null||productIds.size()<=0){
JSONObject jo=new JSONObject();
jo.put("total",0);
jo.put("page_total",0);
jo.put("page",1);
jo.put("page_size",0);
jo.put("total",total);
jo.put("page_total",total%pageSize==0?total/pageSize:((total/pageSize)+1));
jo.put("page",frontPage);
jo.put("page_size",pageSize);
jo.put("product_list",new ArrayList<>());
return new com.yohoufo.common.ApiResponse.ApiResponseBuilder().data(jo).code(200).message("listFavorite data is null").build();
}
... ... @@ -78,6 +81,17 @@ public class FavoriteController {
,limit,page
);
if(productApiResponse!=null&&productApiResponse.getData()!=null){
JSONObject jo=(JSONObject)productApiResponse.getData();
jo.put("total", total);
jo.put("page_total",total%pageSize==0?total/pageSize:((total/pageSize)+1));
jo.put("page",frontPage);
jo.put("page_size",pageSize);
//重设
productApiResponse.setData(jo);
}
logger.info("After call ufo.user.favoriteList result productIds is {} ,productApiResponse is {} ", productIds ,productApiResponse);
return productApiResponse;
}
... ...
... ... @@ -68,6 +68,7 @@ yoho.recovery.zkPath=/yh/config/recovery
env.machineId=0
ips.machine=127.0.0.1
wechat.app.partnerid=1218934901
wechat.app.partnerkey=b22de5cfd0ded341e0516505f72649a9
... ...
... ... @@ -26,7 +26,7 @@ web.context=ufo-gateway
#\u5bc6\u7801AES\u52a0\u5bc6\u5bc6\u94a5
password.aes.key=${password.aes.key}
uic.service.url=${uic.service.url}
#Ϣ-url
#��Ϣ����-����url
inbox.baseurl=${inbox.baseurl}
#signature encrypt key salt
... ... @@ -65,4 +65,7 @@ order.seller.earnestMoneyRate=${order.seller.earnestMoneyRate}
order.seller.payChannelRate=${order.seller.payChannelRate}
erp-gateway.url=${erp-gateway.url}
uic.url=${uic.url}
yoho.message.controller.url=${yoho.message.controller.url}
\ No newline at end of file
yoho.message.controller.url=${yoho.message.controller.url}
ips.machine=${ips.machine}
\ No newline at end of file
... ...
... ... @@ -31,6 +31,7 @@
<url-pattern>/html/h5Share/css/goodsDetail.css</url-pattern>
<url-pattern>/html/h5Share/js/swiper-4.4.1.min.js</url-pattern>
<url-pattern>/html/h5Share/js/jquery-1.11.3.min.js</url-pattern>
<url-pattern>/html/h5Share/js/share.js</url-pattern>
<url-pattern>/html/h5Share/css/font/din_alternate_bold.eot</url-pattern>
<url-pattern>/html/h5Share/css/font/din_alternate_bold.svg</url-pattern>
<url-pattern>/html/h5Share/css/font/din_alternate_bold.ttf</url-pattern>
... ...
... ... @@ -114,21 +114,8 @@ a {
.goods-detail-page .goods-dec {
width: 16.75rem;
height: 2.5rem;
line-height: 2.3rem;
margin: 1.5rem auto 1.8rem;
border: 1px solid #000;
font-family: PingFang-SC-Light;
font-size: 0.8rem;
color: #000;
letter-spacing: 0;
text-align: center;
}
.goods-detail-page .goods-dec .c:before {
content: "\00D7";
display: inline-block;
margin: 0 0.2rem;
font-size: 1.2rem;
display: block;
}
.goods-detail-page .head {
... ...
... ... @@ -8,8 +8,8 @@
<script type="text/javascript">
(function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=750){e.style.fontSize="40px"}else{e.style.fontSize=40*(f/750)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window);
</script>
<link href="./css/swiper-4.4.1.min.css" rel="stylesheet" type="text/css"/>
<link href="./css/goodsDetail.css" rel="stylesheet" type="text/css"/>
<link href="https://cdn.yoho.cn/ufo/1.0.1/css/swiper-4.4.1.min.css" rel="stylesheet" type="text/css"/>
<link href="https://cdn.yoho.cn/ufo/1.0.1/css/goodsDetail.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
</head>
<body>
... ... @@ -54,15 +54,13 @@
</li>
</ul>
<div class="goods-dec">
正品保障<span class="c"></span>专业鉴定<span class="c"></span>银联担保
</div>
<img src="https://cdn.yoho.cn/ufoapp/productdetail/service.png" class="goods-dec">
</div>
<script src="./js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="./js/swiper-4.4.1.min.js" type="text/javascript"></script>
<script src="./js/share.js"></script>
<script src="https://cdn.yoho.cn/ufo/1.0.1/js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="https://cdn.yoho.cn/ufo/1.0.1/js/swiper-4.4.1.min.js" type="text/javascript"></script>
<script src="https://cdn.yoho.cn/ufo/1.0.1/js/share.js"></script>
<script>
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
... ...