Authored by chenchao

implement service

package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface AppraiseOrderGoodsMapper {
... ... @@ -8,9 +11,11 @@ public interface AppraiseOrderGoodsMapper {
int insertSelective(AppraiseOrderGoods record);
AppraiseOrderGoods selectByPrimaryKey(Integer id);
AppraiseOrderGoods selectByOrderCode(Long orderCode);
int updateByPrimaryKeySelective(AppraiseOrderGoods record);
int updateByPrimaryKey(AppraiseOrderGoods record);
List<AppraiseOrderGoods> selectByOrderCodes(@Param("orderCodes") List<Long> orderCodes);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.AppraiseOrder;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface AppraiseOrderMapper {
... ... @@ -8,9 +12,22 @@ public interface AppraiseOrderMapper {
int insertSelective(AppraiseOrder record);
AppraiseOrder selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AppraiseOrder record);
int updateByPrimaryKey(AppraiseOrder record);
List<AppraiseOrder> selectSubOrderList(long parentOrderCode);
AppraiseOrder selectByOrderCode(long orderCode);
int selectCntByOrderType(@Param("uid") int uid,
@Param("attributes") int attributes,
@Param("statusList")Collection<Integer> statusList);
List<AppraiseOrder> selectOrderListByOrderType(@Param("uid") int uid,
@Param("attributes") int attributes,
@Param("statusList")Collection<Integer> statusList,
@Param("offset")int offset,
@Param("limit")int limit);
}
\ No newline at end of file
... ...
... ... @@ -2,8 +2,10 @@ package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.AppraiseOrderMeta;
import java.util.List;
public interface AppraiseOrderMetaMapper {
int deleteByPrimaryKey(Integer id);
int insertBatch(List<AppraiseOrderMeta> list);
int insert(AppraiseOrderMeta record);
... ... @@ -11,7 +13,8 @@ public interface AppraiseOrderMetaMapper {
AppraiseOrderMeta selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AppraiseOrderMeta record);
AppraiseOrderMeta selectByOrderCode(AppraiseOrderMeta condition);
int updateByPrimaryKey(AppraiseOrderMeta record);
AppraiseOrderMeta selectByOrderCodeStorageId(AppraiseOrderMeta condition);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor@NoArgsConstructor
public class AppraiseOrderGoods {
private Integer id;
... ...
... ... @@ -14,11 +14,11 @@
<sql id="Base_Column_List">
id, order_code, product_id, product_name, product_code, image_url, depot_no, num
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<select id="selectByOrderCode" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from appraise_order_goods
where id = #{id,jdbcType=INTEGER}
where order_code = #{orderCode,jdbcType=BIGINT}
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.AppraiseOrderGoods" useGeneratedKeys="true">
... ... @@ -117,4 +117,13 @@
num = #{num,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByOrderCodes" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from appraise_order_goods
where order_code in
<foreach collection="orderCodes" item="orderCode" open="(" close=")" separator=",">
#{orderCode,jdbcType=BIGINT}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -22,11 +22,40 @@
id, uid, parent_order_code, order_code, client_type, payment, amount, ship_fee, status,
create_time, update_time, is_del, channel_no, attributes, platform_delivery_status
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<select id="selectSubOrderList" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from appraise_order
where id = #{id,jdbcType=INTEGER}
where parent_order_code = #{parentOrderCode,jdbcType=INTEGER}
</select>
<select id="selectByOrderCode" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from appraise_order
where order_code = #{orderCode,jdbcType=INTEGER}
</select>
<select id="selectCntByOrderType" resultType="java.lang.Integer">
select count(*) from appraise_order
where uid = #{uid,jdbcType=INTEGER} and attributes = #{attributes,jdbcType=INTEGER}
and status in
<foreach collection="statusList" item="status" open="(" close=")" separator=",">
#{status,jdbcType=TINYINT}
</foreach>
</select>
<select id="selectOrderListByOrderType" resultType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from appraise_order
where uid = #{uid,jdbcType=INTEGER} and attributes = #{attributes,jdbcType=INTEGER}
and status in
<foreach collection="statusList" item="status" open="(" close=")" separator=",">
#{status,jdbcType=TINYINT}
</foreach>
limit #{offset},#{limit}
</select>
... ... @@ -42,6 +71,7 @@
#{updateTime,jdbcType=INTEGER}, #{isDel,jdbcType=TINYINT}, #{channelNo,jdbcType=VARCHAR},
#{attributes,jdbcType=INTEGER}, #{platformDeliveryStatus,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.AppraiseOrder" useGeneratedKeys="true">
insert into appraise_order
<trim prefix="(" suffix=")" suffixOverrides=",">
... ... @@ -136,67 +166,23 @@
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.AppraiseOrder">
update appraise_order
<set>
<if test="uid != null">
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="parentOrderCode != null">
parent_order_code = #{parentOrderCode,jdbcType=BIGINT},
</if>
<if test="orderCode != null">
order_code = #{orderCode,jdbcType=BIGINT},
</if>
<if test="clientType != null">
client_type = #{clientType,jdbcType=TINYINT},
</if>
<if test="payment != null">
payment = #{payment,jdbcType=TINYINT},
</if>
<if test="amount != null">
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="shipFee != null">
ship_fee = #{shipFee,jdbcType=DECIMAL},
</if>
<if test="status != null">
status = #{status,jdbcType=TINYINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=INTEGER},
</if>
<if test="isDel != null">
is_del = #{isDel,jdbcType=TINYINT},
</if>
<if test="channelNo != null">
channel_no = #{channelNo,jdbcType=VARCHAR},
</if>
<if test="attributes != null">
attributes = #{attributes,jdbcType=INTEGER},
</if>
<if test="platformDeliveryStatus != null">
platform_delivery_status = #{platformDeliveryStatus,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.AppraiseOrder">
update appraise_order
set uid = #{uid,jdbcType=INTEGER},
parent_order_code = #{parentOrderCode,jdbcType=BIGINT},
order_code = #{orderCode,jdbcType=BIGINT},
client_type = #{clientType,jdbcType=TINYINT},
payment = #{payment,jdbcType=TINYINT},
amount = #{amount,jdbcType=DECIMAL},
ship_fee = #{shipFee,jdbcType=DECIMAL},
status = #{status,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
is_del = #{isDel,jdbcType=TINYINT},
channel_no = #{channelNo,jdbcType=VARCHAR},
attributes = #{attributes,jdbcType=INTEGER},
platform_delivery_status = #{platformDeliveryStatus,jdbcType=TINYINT}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -26,6 +26,16 @@
values (#{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{storageId,jdbcType=INTEGER},
#{metaKey,jdbcType=VARCHAR}, #{metaValue,jdbcType=VARCHAR})
</insert>
<insert id="insertBatch" parameterType="java.util.List">
insert into appraise_order_meta (uid, order_code, storage_id, meta_key, meta_value)
values
<foreach collection="list" item="record" separator=",">
(#{record.uid,jdbcType=INTEGER}, #{record.orderCode,jdbcType=BIGINT}, #{record.storageId,jdbcType=INTEGER},
#{record.metaKey,jdbcType=VARCHAR}, #{record.metaValue,jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.AppraiseOrderMeta" useGeneratedKeys="true">
insert into appraise_order_meta
<trim prefix="(" suffix=")" suffixOverrides=",">
... ... @@ -63,34 +73,23 @@
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.AppraiseOrderMeta">
update appraise_order_meta
<set>
<if test="uid != null">
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="orderCode != null">
order_code = #{orderCode,jdbcType=BIGINT},
</if>
<if test="storageId != null">
storage_id = #{storageId,jdbcType=INTEGER},
</if>
<if test="metaKey != null">
meta_key = #{metaKey,jdbcType=VARCHAR},
</if>
<if test="metaValue != null">
meta_value = #{metaValue,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.AppraiseOrderMeta">
update appraise_order_meta
set uid = #{uid,jdbcType=INTEGER},
order_code = #{orderCode,jdbcType=BIGINT},
storage_id = #{storageId,jdbcType=INTEGER},
meta_key = #{metaKey,jdbcType=VARCHAR},
meta_value = #{metaValue,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByOrderCode" parameterType="com.yohoufo.dal.order.model.AppraiseOrderMeta" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from appraise_order_meta
where order_code = #{orderCode,jdbcType=INTEGER}
and meta_key = #{metaKey,jdbcType=VARCHAR}
</select>
<select id="selectByOrderCodeStorageId" parameterType="com.yohoufo.dal.order.model.AppraiseOrderMeta" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from appraise_order_meta
where order_code = #{orderCode,jdbcType=INTEGER}
and storage_id = #{storageId,jdbcType=INTEGER}
and meta_key = #{metaKey,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -4,10 +4,7 @@ import com.yohobuy.ufo.model.order.req.AppraiseOrderComputeReq;
import com.yohobuy.ufo.model.order.req.AppraiseOrderDetailReq;
import com.yohobuy.ufo.model.order.req.AppraiseOrderListReq;
import com.yohobuy.ufo.model.order.req.AppraiseOrderSubmitReq;
import com.yohobuy.ufo.model.order.resp.AppraiseOrderComputeResp;
import com.yohobuy.ufo.model.order.resp.AppraiseOrderDetailResp;
import com.yohobuy.ufo.model.order.resp.AppraiseOrderListResp;
import com.yohobuy.ufo.model.order.resp.AppraiseOrderSubmitResp;
import com.yohobuy.ufo.model.order.resp.*;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.service.impl.AppraiseOrderService;
import org.slf4j.Logger;
... ... @@ -51,9 +48,12 @@ public class AppraiseOrderController {
@RequestMapping(params = "method=ufo.appraiseOrder.submit")
public ApiResponse submit(@RequestParam(name = "uid")int uid,
@RequestParam(name = "productId")int productId,
@RequestParam(name = "addressId") String addressId){
@RequestParam(name = "addressId") String addressId,
@RequestParam(name = "channelNo", required = false) String channelNo,
@RequestParam(name = "client_type", required = false) String clientType){
AppraiseOrderSubmitReq req = AppraiseOrderSubmitReq.builder()
.uid(uid).productId(productId).addressId(addressId).build();
.uid(uid).productId(productId).addressId(addressId)
.channelNo(channelNo).clientType(clientType).build();
logger.info("in ufo.appraiseOrder.submit req {}", req);
AppraiseOrderSubmitResp resp = appraiseOrderService.submit(req);
return new ApiResponse.ApiResponseBuilder()
... ... @@ -78,7 +78,7 @@ public class AppraiseOrderController {
.uid(uid).limit(limit).page(page).build();
logger.info("in ufo.appraiseOrder.list req {}", req);
AppraiseOrderListResp resp = appraiseOrderService.getOrderList(req);
PageResp<AppraiseOrderListResp> resp = appraiseOrderService.getOrderList(req);
return new ApiResponse.ApiResponseBuilder()
.code(200)
.data(resp)
... ...
package com.yohoufo.order.convert;
import com.yohobuy.ufo.model.order.resp.AppraiseOrderListResp;
public final class AppraiseOrderConverter {
public static AppraiseOrderListResp do2Resp(){
return null;
}
}
... ...
package com.yohoufo.order.convert;
import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
public final class AppraiseOrderGoodsConvertor {
public static AppraiseOrderGoodsBo do2Bo(AppraiseOrderGoods paog){
return AppraiseOrderGoodsBo.builder()
.productId(paog.getProductId())
.productName(paog.getProductName())
.productCode(paog.getProductCode())
.imageUrl(ImageUrlAssist.getAllProductPicUrl(paog.getImageUrl(), "goodsimg", "center", "d2hpdGU="))
.build();
}
}
... ...
... ... @@ -21,6 +21,9 @@ public class AppraiseOrderContext {
private int productId;
private Integer clientType;
private String channelNo;
/**
* 鉴定费
*/
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
import com.yohoufo.dal.order.AppraiseOrderMapper;
import com.yohoufo.dal.order.BuyerOrderMetaMapper;
import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
import com.yohoufo.dal.order.model.AppraiseOrder;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
import com.yohoufo.dal.order.model.BuyerOrderMeta;
import com.yohoufo.dal.order.model.AppraiseOrderMeta;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.dto.AppraiseOrderContext;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -18,6 +21,8 @@ import lombok.Data;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
... ... @@ -35,7 +40,7 @@ public class AppraiseOrderCreateService {
private AppraiseOrderGoodsMapper appraiseOrderGoodsMapper;
@Autowired
private BuyerOrderMetaMapper buyerOrderMetaMapper;
private AppraiseOrderMetaMapper appraiseOrderMetaMapper;
@Builder
@Data
... ... @@ -45,6 +50,8 @@ public class AppraiseOrderCreateService {
AppraiseOrderGoods appraiseOrderGoods;
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Database(ForceMaster=true, DataSource="ufo_order")
public SubmitResult create(AppraiseOrderContext ctx){
logger.info("in AppraiseOrderCreateService create, ");
int uid = ctx.getUid();
... ... @@ -53,10 +60,18 @@ public class AppraiseOrderCreateService {
uid, orderCode, ctx.getProductId());
//
AppraiseOrder pao = new AppraiseOrder();
pao.setUid(ctx.getUid());
pao.setOrderCode(orderCode);
pao.setAmount(ctx.getFee());
//TODO
int cdt = DateUtil.getCurrentTimeSecond();
pao.setCreateTime(cdt);
pao.setUpdateTime(cdt);
//
pao.setStatus(AppraiseOrderStatus.WAITING_PAY.getCode());
pao.setIsDel(DelStatus.NOT_DEL.getCode());
pao.setChannelNo(ctx.getChannelNo());
pao.setClientType(ctx.getClientType());
appraiseOrderMapper.insertSelective(pao);
//
AppraiseOrderGoodsBo aogb = ctx.getGoodsBo();
... ... @@ -65,28 +80,29 @@ public class AppraiseOrderCreateService {
paog.setProductId(aogb.getProductId());
paog.setProductName(aogb.getProductName());
paog.setProductCode(aogb.getProductCode());
paog.setNum(1);
appraiseOrderGoodsMapper.insertSelective(paog);
//meta
AddressInfo noHiddenBackAddress = ctx.getBackAddress(),
hiddenBackAddress = ctx.getBackHiddenAddress();
final String key = MetaKey.BUYER_DELIVERY_ADDRESS,
hiiden_key = MetaKey.BUYER_DELIVERY_HIDDEN_ADDRESS;
BuyerOrderMeta noHiddenAddressMeta=new BuyerOrderMeta();
hidden_key = MetaKey.BUYER_DELIVERY_HIDDEN_ADDRESS;
AppraiseOrderMeta noHiddenAddressMeta = new AppraiseOrderMeta();
noHiddenAddressMeta.setUid(uid);
noHiddenAddressMeta.setOrderCode(orderCode);
noHiddenAddressMeta.setMetaKey(key);
noHiddenAddressMeta.setMetaValue(JSONObject.toJSONString(noHiddenBackAddress));
//hidden address
BuyerOrderMeta hiddenAddressMeta=new BuyerOrderMeta();
AppraiseOrderMeta hiddenAddressMeta = new AppraiseOrderMeta();
hiddenAddressMeta.setUid(uid);
hiddenAddressMeta.setOrderCode(orderCode);
hiddenAddressMeta.setMetaKey(hiiden_key);
hiddenAddressMeta.setMetaKey(hidden_key);
hiddenAddressMeta.setMetaValue(JSONObject.toJSONString(hiddenBackAddress));
List<BuyerOrderMeta> boms = new ArrayList<>(2);
List<AppraiseOrderMeta> boms = new ArrayList<>(2);
boms.add(noHiddenAddressMeta);
boms.add(hiddenAddressMeta);
buyerOrderMetaMapper.insertBatch(boms);
appraiseOrderMetaMapper.insertBatch(boms);
return SubmitResult.builder().appraiseOrder(pao).appraiseOrderGoods(paog).build();
}
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.req.AppraiseOrderComputeReq;
import com.yohobuy.ufo.model.order.req.AppraiseOrderDetailReq;
import com.yohobuy.ufo.model.order.req.AppraiseOrderListReq;
import com.yohobuy.ufo.model.order.req.AppraiseOrderSubmitReq;
import com.yohobuy.ufo.model.order.resp.AppraiseOrderComputeResp;
import com.yohobuy.ufo.model.order.resp.AppraiseOrderDetailResp;
import com.yohobuy.ufo.model.order.resp.AppraiseOrderListResp;
import com.yohobuy.ufo.model.order.resp.AppraiseOrderSubmitResp;
import com.yohobuy.ufo.model.order.resp.*;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.AddressUtil;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
import com.yohoufo.dal.order.AppraiseOrderMapper;
import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
import com.yohoufo.dal.order.model.AppraiseOrder;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
import com.yohoufo.dal.order.model.AppraiseOrderMeta;
import com.yohoufo.dal.order.model.QiniuLiveRecord;
import com.yohoufo.order.common.ClientType;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.convert.AppraiseOrderGoodsConvertor;
import com.yohoufo.order.model.dto.AppraiseOrderContext;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
... ... @@ -31,7 +39,10 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
public class AppraiseOrderService {
... ... @@ -51,7 +62,13 @@ public class AppraiseOrderService {
@Autowired
OrderCodeGenerator orderCodeGenerator;
private OrderCodeGenerator orderCodeGenerator;
@Autowired
private AppraiseOrderMetaMapper appraiseOrderMetaMapper;
@Autowired
private QiniuLiveRecordService qiniuLiveRecordService;
public AppraiseOrderComputeResp compute(AppraiseOrderComputeReq req){
... ... @@ -64,24 +81,7 @@ public class AppraiseOrderService {
if (productId <= 0){
throw new UfoServiceException(400, "商品ID错误");
}
int orderType = req.getOrderType();
OrderAttributes orderAttributes = checkOrderType(orderType);
double fee = 0D;
switch (orderAttributes){
case DEPOSITE:{
fee = 15D;
break;
}
case APPRAISE:{
fee = 31D;
break;
}
default:{
throw new UfoServiceException(400, "orderType错误");
}
}
double fee = 15D;
return AppraiseOrderComputeResp.builder().fee(String.valueOf(fee)).build();
}
... ... @@ -91,6 +91,7 @@ public class AppraiseOrderService {
add(OrderAttributes.APPRAISE);
}
};
private OrderAttributes checkOrderType(int orderType){
OrderAttributes oa = OrderAttributes.getOrderAttributes(orderType);
if (Objects.isNull(oa) || !legalOrderTypes.contains(oa)){
... ... @@ -110,8 +111,6 @@ public class AppraiseOrderService {
AppraiseOrderGoodsBo aog = new AppraiseOrderGoodsBo();
//TODO dependency product service support produce data
AppraiseOrderContext aoc = AppraiseOrderContext.builder()
.orderCode(orderCode)
.uid(pn.getUid())
... ... @@ -119,6 +118,8 @@ public class AppraiseOrderService {
.backAddress(pn.getNoHiddenBackAddress())
.backHiddenAddress(pn.getHiddenBackAddress())
.goodsBo(aog)
.channelNo(req.getChannelNo())
.clientType(ClientType.getClientType(req.getClientType()))
.build();
//2 persistent key info
... ... @@ -128,6 +129,8 @@ public class AppraiseOrderService {
AppraiseOrderCreateService.SubmitResult submitResult = appraiseOrderCreateService.create(aoc);
//todo notice by async
//resp
AppraiseOrderSubmitResp aosr = new AppraiseOrderSubmitResp();
aosr.setOrderCode(orderCode);
return aosr;
... ... @@ -143,6 +146,10 @@ public class AppraiseOrderService {
OrderAttributes orderAttributes;
}
OrderAttributes getOrderAttributes(){
return OrderAttributes.APPRAISE;
}
private PreparedNode checkAndAcquire(AppraiseOrderSubmitReq req){
int uid = req.getUid();
if (uid<=0){
... ... @@ -152,7 +159,7 @@ public class AppraiseOrderService {
if (productId <= 0){
throw new UfoServiceException(400, "商品ID错误");
}
OrderAttributes orderAttributes = OrderAttributes.APPRAISE;
final OrderAttributes orderAttributes = getOrderAttributes();
int addressId = AddressUtil.getDecryptStr(req.getAddressId());
if (addressId < 0){
... ... @@ -179,23 +186,151 @@ public class AppraiseOrderService {
.build();
}
List<Integer> getLegalStatus(){
return new ArrayList<Integer>(){
{
add(AppraiseOrderStatus.HAS_PAYED.getCode());
add(AppraiseOrderStatus.SELLER_SEND_OUT.getCode());
add(AppraiseOrderStatus.PLATFORM_RECEIVE.getCode());
add(AppraiseOrderStatus.JUDGE_PASS.getCode());
add(AppraiseOrderStatus.WAITING_RECEIVE.getCode());
add(AppraiseOrderStatus.CHECKING_FAKE.getCode());
add(AppraiseOrderStatus.SHAM_SEND_OUT.getCode());
add(AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode());
}
};
}
public PageResp<AppraiseOrderListResp> getOrderList(AppraiseOrderListReq req){
PageResp.PageRespBuilder respBuilder = PageResp.builder();
int uid = req.getUid();
OrderAttributes orderAttributes = getOrderAttributes();
final List<Integer> statusList = getLegalStatus();
int total = appraiseOrderMapper.selectCntByOrderType(uid, orderAttributes.getCode(), statusList);
int limit = req.getLimit();
if (total == 0){
return respBuilder
.pageSize(limit)
.total(total)
.page(req.getPage())
.build();
}
public AppraiseOrderListResp getOrderList(AppraiseOrderListReq req){
int offset = (req.getPage() - 1) * limit;
List<AppraiseOrder> orderList = appraiseOrderMapper.selectOrderListByOrderType(uid, orderAttributes.getCode(), statusList, offset, limit);
return null;
List<Long> orderCodes = orderList.stream().map(AppraiseOrder::getOrderCode).collect(Collectors.toList());
List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectByOrderCodes(orderCodes);
Map<Long,AppraiseOrderGoods> orderCodeAOGMap = paogs.stream().collect(Collectors.toMap(AppraiseOrderGoods::getOrderCode, Function.identity()));
List<AppraiseOrderListResp> aolrList = orderList.parallelStream()
.map(pao-> buildAppraiseOrderListResp(pao, orderCodeAOGMap.get(pao.getOrderCode())))
.collect(Collectors.toList());
respBuilder.page(req.getPage())
.pageSize(limit)
.total(total)
.pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1))
.data(aolrList);
return respBuilder.build();
}
AppraiseOrderListResp buildAppraiseOrderListResp(AppraiseOrder pao, AppraiseOrderGoods paog){
Integer uid = pao.getUid();
Long orderCode = pao.getOrderCode();
Integer status = pao.getStatus();
AppraiseOrderStatus aos = AppraiseOrderStatus.getByCode(status);
AppraiseOrderListResp resp = AppraiseOrderListResp.builder()
.uid(uid)
.orderCode(orderCode)
.goodsInfo(AppraiseOrderGoodsConvertor.do2Bo(paog))
.buttons(Objects.nonNull(aos) ? aos.listButtons() : null)
.statuStr(Objects.nonNull(aos) ? aos.statusStr() : "")
.status(status)
.build();
return resp;
}
public AppraiseOrderDetailResp getOrderDetail(AppraiseOrderDetailReq req){
int uid = req.getUid();
long orderCode = req.getOrderCode();
return null;
AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
if (Objects.isNull(pao)){
logger.warn("in getOrderDetail of appraise order null ,req {}", req);
return null;
}
Integer aoac = pao.getAttributes();
OrderAttributes oa = OrderAttributes.getOrderAttributes(aoac);
if (Objects.isNull(oa) || !getOrderAttributes().equals(oa)){
logger.warn("in getOrderDetail of appraise order attr is null ,req {}", req);
return null;
}
AppraiseOrderGoods paog = appraiseOrderGoodsMapper.selectByOrderCode(orderCode);
Integer status = pao.getStatus();
AppraiseOrderStatus aos = AppraiseOrderStatus.getByCode(status);
//
OrderDetailInfo.StatusDetail statusDetail = OrderDetailInfo.StatusDetail
.builder().status(status)
.statuStr(aos.statusStr())
.detailDesc(aos.detailDesc()).build();
//
String hidden_key = MetaKey.BUYER_DELIVERY_HIDDEN_ADDRESS;
AppraiseOrderMeta aomc = new AppraiseOrderMeta();
aomc.setOrderCode(orderCode);
aomc.setMetaKey(hidden_key);
AppraiseOrderMeta paom = appraiseOrderMetaMapper.selectByOrderCode(aomc);
AppraiseAddressInfo appraiseAddressInfo = null;
if (Objects.nonNull(paom)){
try {
appraiseAddressInfo = JSONObject.parseObject(paom.getMetaValue(), AppraiseAddressInfo.class);
}catch (Exception ex){
logger.warn("in get detail of appraise order ");
}
}
String appraiseVideoUrl = null;
QiniuLiveRecord qiniuLiveRecord = qiniuLiveRecordService.getByOrderCode(orderCode);
if (Objects.nonNull(qiniuLiveRecord)){
appraiseVideoUrl = qiniuLiveRecord.getVideoUrl();
}
AppraiseOrderDetailResp aodResp = AppraiseOrderDetailResp.builder()
.uid(uid).orderCode(orderCode)
.statusDetail(statusDetail)
.createTime(DateUtil.formatDate(pao.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS))
.goodsInfo(AppraiseOrderGoodsConvertor.do2Bo(paog))
.appraiseAddress(appraiseAddressInfo)
.appraiseVideoUrl(appraiseVideoUrl)
.build();
return aodResp;
}
/**
* 是否付费鉴定订单
* @param uid
* @param orderCode
* @return
*/
public boolean isAppraiseOrder(int uid, long orderCode){
return false;
AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
Integer aoac = null;
OrderAttributes oa = null;
boolean flag = Objects.nonNull(pao)
&& Objects.nonNull(aoac=pao.getAttributes())
&& Objects.nonNull(oa = OrderAttributes.getOrderAttributes(aoac))
&& Objects.equals(oa, OrderAttributes.APPRAISE);
logger.info("in isAppraiseOrder uid {} orderCode {} aoac {} oa {} flag {}",
uid, orderCode, aoac, oa, flag);
return flag;
}
/**
... ... @@ -208,7 +343,7 @@ public class AppraiseOrderService {
}
/**
*
* 平台收货
* @param orderCode
*/
public void platformReceiveGoods(long orderCode){
... ... @@ -216,7 +351,7 @@ public class AppraiseOrderService {
}
/**
*
* 鉴定通过
* @param orderCode
*/
public void appraisePass(long orderCode){
... ...
... ... @@ -83,7 +83,7 @@ public class QiniuLiveRecordService {
qiniuLiveRecordMapper.insert(qiniuLiveRecords);
}
public QiniuLiveRecord selectByOrderCodes(Long orderCode) {
public QiniuLiveRecord getByOrderCode(Long orderCode) {
if (null == orderCode) {
return null;
}
... ...