Authored by csgyoho

Merge branch 'dev-margin-20181207' into test6.8.3

# Conflicts:
#	order/src/main/java/com/yoho/ufo/order/service/impl/BuyerOrderServiceImpl.java
package com.yoho.order.dal;
import java.util.List;
import com.yoho.order.model.SellerWalletDetail;
import org.apache.ibatis.annotations.Param;
import com.yoho.order.model.SellerWalletDetail;
import java.util.List;
public interface SellerWalletDetailMapper {
//查询用户违约的次数
int selectUserBreakRulesCount(@Param("uid") Integer uid);
List<SellerWalletDetail> selectMerchantInfo(@Param("uid") Integer uid,
@Param("startTime") Integer stratTime,
@Param("endTime") Integer endTime,
@Param("stateList") List<Integer> stateList,
@Param("start") int start,
@Param("rows") Integer rows);
int selectMerchantInfoCount(@Param("uid") Integer uid,
@Param("startTime") Integer stratTime,
@Param("endTime") Integer endTime,
@Param("stateList") List<Integer> stateList);
List<SellerWalletDetail> selectMerchantInfo(@Param("uids") List<Integer> uids,
@Param("startTime") Integer stratTime,
@Param("endTime") Integer endTime,
@Param("stateList") List<Integer> stateList,
@Param("orderCode") String orderCode, @Param("start") int start,
@Param("rows") Integer rows);
int selectMerchantInfoCount(@Param("uids") List<Integer> uids,
@Param("startTime") Integer stratTime,
@Param("endTime") Integer endTime,
@Param("stateList") List<Integer> stateList, @Param("orderCode") String orderCode);
SellerWalletDetail selectById(Integer id);
}
\ No newline at end of file
... ...
package com.yoho.order.dal;
import com.yoho.order.model.SellerWallet;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Created by shengguo.cai on 2018/12/7.
*/
public interface SellerWalletMapper {
int selectTotalByUidAndMerchantUids(@Param("uid") String uid, @Param("merchantUids") List<Integer> merchantUids);
List<SellerWallet> selectByUidAndMerchantUids(@Param("uid") String uid, @Param("merchantUids") List<Integer> merchantUids, @Param("start") int start, @Param("size") int size);
}
... ...
... ... @@ -2,16 +2,21 @@ package com.yoho.order.dal;
import com.yoho.order.model.StoredSeller;
import com.yoho.order.model.StoredSellerReqVo;
import com.yoho.order.model.TradeBills;
import com.yoho.order.model.TradeBillsReq;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface StoredSellerMapper {
int selectCountByCondition(@Param("storedSellerReq") StoredSellerReqVo req);
List<StoredSeller> selectByConditionWithPage(@Param("storedSellerReq") StoredSellerReqVo req);
@MapKey("uid")
Map<Integer,Map<String,Object>> selectNameByUids(@Param("uids") List<Integer> uids);
List<Integer> selectUidByCertName(@Param("certName") String certName);
List<Integer> selectUidByCertNameAndUid(@Param("merchantName") String merchantName, @Param("uid") String uid);
}
... ...
package com.yoho.order.model;
import java.util.List;
import com.yoho.ufo.service.model.PageRequestBO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
@Data
@ToString
@EqualsAndHashCode(callSuper=false)
... ... @@ -17,12 +16,16 @@ public class MerchantReq extends PageRequestBO {
private Integer id;
private Integer uid;
private String uid;
private String startTime;
private String endTime;
private List<Integer> stateList;
private String merchantName;
private String orderCode;
}
... ...
package com.yoho.order.model;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
/**
* Created by shengguo.cai on 2018/12/7.
*/
@Data
@ToString
public class SellerWallet {
private Integer id;
private Integer uid;
private BigDecimal amount;
private BigDecimal lockAmount;
private Integer status;
private Integer type;
private Integer createTime;
private Integer updateTime;
}
... ...
... ... @@ -38,37 +38,59 @@ public class SellerWalletDetail {
// 41买家取消(无物流), 42买家取消(有物流),
// 51鉴定通过,
// 61退还保证金(退出商家)
RE_CHARGE("充值保证金", 1),
PUBLISH("卖家发布商品", 11),
ADD_PRICE("卖家调高商品价格", 11),
SUBTRACT_PRICE("卖家调低商品价格", 11),
SELLER_OFF("卖家下架商品", 11),
SYSTEM_OFF("系统下架商品", 11),
SELLER_CANCEL("卖家不卖了", 11),
SELLER_OVER_TIME("卖家发货超时", 11),
APPRAISE_FAIL("鉴定不通过", 11),
BUYER_CANCEL_NO_DELIVERY("买家取消(无物流)", 11),
BUYER_CANCEL_DELIVERY("买家取消(有物流)", 11),
APPRAISE_OK("鉴定通过", 11),
MERCHANT_EXIT("商家退出入驻", 11);
RE_CHARGE("充值保证金", new int[]{1}),
SELLER_ONSHELF("卖家上架商品", new int[]{11}),
SELLER_ADDPRICE("卖家上调价格", new int[]{12}),
TRADE_COMPLETE("商品交易完成", new int[]{51}),
SELLER_REDUCEPRICE("卖家下调价格", new int[]{13}),
SELLER_OFFSHELF("卖家下架商品", new int[]{21}),
SYSTEM_OFFSHELF("系统下架商品", new int[]{22}),
SELLER_TRADEFAILED("卖家原因交易失败", new int[]{31,32,33}),
BUYER_CANCEL("买家付款后取消订单", new int[]{41,42}),
SELLER_QUIT("卖家退出入驻", new int[]{61});
private String name;
private int value;
private int[] value;
private Type(String name, int value) {
private Type(String name, int[] value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public int getValue() {
public int[] getValue() {
return value;
}
public static Type of(int value) {
/**
* 只要value属于枚举类中的value的子集就行(包含于)
* @param value
* @return
*/
public static Type of(int[] value) {
if(value == null || value.length == 0){
return null;
}
for (Type t : values()) {
if (t.value == value) {
boolean isFind=true;
if(t.value.length<value.length){
continue;
}
for(int val : value){
boolean flag=true;
for(int cVal : t.value){
if(val == cVal){
flag=false;
break;
}
}
if(flag){
isFind=false;
break;
}
}
if(isFind){
return t;
}
}
... ...
package com.yoho.ufo.model.goodsmanage;
import com.yoho.ufo.dal.model.Product;
import com.yoho.ufo.dal.model.Storage;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
/**
* Created by shengguo.cai on 2018/12/12.
*/
@Data
@EqualsAndHashCode(callSuper=false)
@ToString
public class StorageProductBo {
private Storage storage;
private Product product;
public StorageProductBo(Storage storage, Product product) {
this.storage = storage;
this.product = product;
}
public StorageProductBo(){
}
}
... ...
... ... @@ -43,8 +43,11 @@
where id = #{id,jdbcType=INTEGER}
</select>
<sql id="condi">
<if test="uid != null and uid > 0">
and uid = #{uid,jdbcType=INTEGER}
<if test="uids != null">
and uid in
<foreach collection="uids" item="uid" open="(" close=")" separator=",">
#{uid}
</foreach>
</if>
<if test="startTime != null and startTime > 0">
and create_time &gt;= #{startTime,jdbcType=INTEGER}
... ... @@ -52,6 +55,9 @@
<if test="endTime != null and endTime > 0">
and create_time &lt;= #{endTime,jdbcType=INTEGER}
</if>
<if test="orderCode != null and orderCode != ''">
and order_code=#{orderCode}
</if>
<if test="stateList != null and stateList.size()>0">
and type in
<foreach collection="stateList" item="item" open="(" close=")" separator=",">
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.order.dal.SellerWalletMapper">
<resultMap id="BaseResultMap" type="com.yoho.order.model.SellerWallet" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="amount" property="amount" jdbcType="DECIMAL" />
<result column="lock_amount" property="lockAmount" jdbcType="DECIMAL" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="type" property="type" jdbcType="TINYINT" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, uid, amount,lock_amount,status, type, create_time, update_time
</sql>
<select id="selectTotalByUidAndMerchantUids" resultType="java.lang.Integer">
select count(1) from seller_wallet
<where>
<if test="uid != null and uid != ''">uid=#{uid}</if>
<if test="merchantUids != null">
and uid in
<foreach collection="merchantUids" item="muid" open="(" separator="," close=")">
#{muid}
</foreach>
</if>
</where>
</select>
<select id="selectByUidAndMerchantUids" resultType="com.yoho.order.model.SellerWallet">
select <include refid="Base_Column_List" /> from seller_wallet
<where>
<if test="uid != null and uid != ''">uid=#{uid}</if>
<if test="merchantUids != null">
and uid in
<foreach collection="merchantUids" item="muid" open="(" separator="," close=")">
#{muid}
</foreach>
</if>
</where>
order by id desc limit #{start},#{size}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -49,5 +49,23 @@
order by id desc
limit #{storedSellerReq.start},#{storedSellerReq.size}
</select>
<select id="selectNameByUids" resultType="java.util.Map">
select uid,cert_name from stored_seller
where uid in
<foreach collection="uids" item="uid" open="(" separator="," close=")">
#{uid}
</foreach>
</select>
<select id="selectUidByCertName" resultType="java.lang.Integer">
select uid from stored_seller where cert_name=#{certName}
</select>
<select id="selectUidByCertNameAndUid" resultType="java.lang.Integer">
select uid from stored_seller where 1=1
<if test="merchantName != null and merchantName != ''">
and cert_name=#{merchantName}
</if>
<if test="uid != null and uid !=''">
and uid = #{uid}
</if>
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.ufo.order.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoho.order.model.MerchantReq;
import com.yoho.ufo.order.service.impl.MerchantServiceImpl;
import com.yoho.ufo.service.model.ApiResponse;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/merchant")
... ... @@ -20,7 +19,14 @@ public class MerchantController {
@Autowired
private MerchantServiceImpl service;
@RequestMapping(value = "/listSellerWallets")
public ApiResponse listSellerWallets(MerchantReq req) {
LOGGER.info("listSellerWallets in. req is {}", req);
PageResponseBO<MerchantOrderAttachInfo> result = service.listSellerWallets(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
@RequestMapping(value = "/earnestList")
public ApiResponse earnestList(MerchantReq req) {
LOGGER.info("earnestList in. req is {}", req);
... ...
... ... @@ -25,32 +25,9 @@ import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.order.dal.AppraiseAddressMapper;
import com.yoho.order.dal.AreaMapper;
import com.yoho.order.dal.BuyerOrderGoodsMapper;
import com.yoho.order.dal.BuyerOrderMapper;
import com.yoho.order.dal.BuyerOrderMetaMapper;
import com.yoho.order.dal.ExpressCompanyMapper;
import com.yoho.order.dal.ExpressInfoMapper;
import com.yoho.order.dal.ExpressRecordMapper;
import com.yoho.order.dal.OrderOperateRecordMapper;
import com.yoho.order.dal.OrdersPayMapper;
import com.yoho.order.dal.SellerOrderGoodsMapper;
import com.yoho.order.dal.SellerOrderMapper;
import com.yoho.order.dal.SellerOrderMetaMapper;
import com.yoho.order.model.Area;
import com.yoho.order.model.BuyerOrder;
import com.yoho.order.model.BuyerOrderGoods;
import com.yoho.order.model.BuyerOrderMeta;
import com.yoho.order.model.BuyerOrderReq;
import com.yoho.order.model.ExpressCompany;
import com.yoho.order.model.ExpressInfo;
import com.yoho.order.model.ExpressRecord;
import com.yoho.order.model.OrderOperateRecord;
import com.yoho.order.model.OrdersPay;
import com.yoho.order.model.SellerOrder;
import com.yoho.order.model.SellerOrderGoods;
import com.yoho.order.model.SellerOrderMeta;
import com.yoho.error.exception.ServiceException;
import com.yoho.order.dal.*;
import com.yoho.order.model.*;
import com.yoho.service.model.order.request.OrderRequest;
import com.yoho.ufo.order.constant.Constant;
import com.yoho.ufo.order.service.IBuyerOrderService;
... ... @@ -64,6 +41,24 @@ import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
import com.yohobuy.ufo.model.order.resp.ExpressInfoResp;
import com.yohobuy.ufo.model.order.resp.OrderDetailResp;
import com.yohobuy.ufo.model.order.resp.OrderOperateRecordResp;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.collect.Maps;
import org.elasticsearch.common.netty.util.internal.StringUtil;
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;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* @author caoyan
... ... @@ -115,7 +110,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
private ProductMapper productMapper;
@Autowired
private ServiceCaller serviceCaller;
... ... @@ -175,7 +170,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return resultMap;
}
public PageResponseBO<BuyerOrderResp> queryOrderList(BuyerOrderReq req) {
if(!checkAndBuildParam(req)) {
return null;
... ...
package com.yoho.ufo.order.service.impl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.yoho.order.dal.SellerWalletDetailMapper;
import com.yoho.order.dal.SellerWalletMapper;
import com.yoho.order.dal.StoredSellerMapper;
import com.yoho.order.model.MerchantReq;
import com.yoho.order.model.SellerWallet;
import com.yoho.order.model.SellerWalletDetail;
import com.yoho.ufo.dal.*;
import com.yoho.ufo.dal.model.Goods;
import com.yoho.ufo.dal.model.Product;
import com.yoho.ufo.dal.model.Storage;
import com.yoho.ufo.dal.model.StoragePrice;
import com.yoho.ufo.model.commoditybasicrole.size.Size;
import com.yoho.ufo.model.goodsmanage.StorageProductBo;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -13,12 +23,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.yoho.order.dal.SellerWalletDetailMapper;
import com.yoho.order.model.MerchantReq;
import com.yoho.order.model.SellerWalletDetail;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class MerchantServiceImpl {
... ... @@ -29,35 +38,225 @@ public class MerchantServiceImpl {
@Autowired
private SellerWalletDetailMapper mapper;
@Autowired
private SellerWalletMapper sellerWalletMapper;
@Autowired
private StoredSellerMapper storedSellerMapper;
@Autowired
private ProductMapper productMapper;
@Autowired
private GoodsMapper goodsMapper;
@Autowired
private StorageMapper storageMapper;
@Autowired
private UfoSizeMapper ufoSizeMapper;
@Autowired
private StoragePriceMapper storagePriceMapper;
public MerchantOrderAttachInfo earnestDetail(MerchantReq req) {
return exchange(mapper.selectById(req.getId()));
SellerWalletDetail sellerWalletDetail = mapper.selectById(req.getId());
MerchantOrderAttachInfo info = new MerchantOrderAttachInfo();
if(StringUtils.isNotBlank(sellerWalletDetail.getAttachValue())) {
info = JSON.parseObject(sellerWalletDetail.getAttachValue(), MerchantOrderAttachInfo.class);
}
info.setId(sellerWalletDetail.getId());
info.setUid(sellerWalletDetail.getUid());
info.setType(sellerWalletDetail.getType());
info.setTime(sdf.get().format(new Date(sellerWalletDetail.getCreateTime() * 1000L)));
SellerWalletDetail.Type curType = null;
//如果类型不存在,则不进行处理
if(info.getType()==null || (curType = SellerWalletDetail.Type.of(new int[]{info.getType().intValue()}))==null){
return info;
}
if(curType.equals(SellerWalletDetail.Type.RE_CHARGE)){
return dealReCharge(info,sellerWalletDetail);//保证金充值
}
if(curType.equals(SellerWalletDetail.Type.SELLER_ONSHELF)){
return dealSellerOnShelf(info,sellerWalletDetail);//卖家上架商品
}
if(curType.equals(SellerWalletDetail.Type.SELLER_OFFSHELF)){
return dealSellerOffShelf(info,sellerWalletDetail);//卖家下架商品
}
if(curType.equals(SellerWalletDetail.Type.TRADE_COMPLETE)){
return dealTradeComplete(info,sellerWalletDetail);//商品交易完成
}
if(curType.equals(SellerWalletDetail.Type.SELLER_TRADEFAILED)){
return dealSellerTradeFailed(info,sellerWalletDetail);//卖家原因交易失败
}
if(curType.equals(SellerWalletDetail.Type.SELLER_ADDPRICE)){
return dealSellerAddPrice(info,sellerWalletDetail);//卖家上调价格
}
if(curType.equals(SellerWalletDetail.Type.SELLER_REDUCEPRICE)){
return dealSellerReducePrice(info,sellerWalletDetail);//卖家下调价格
}
if(curType.equals(SellerWalletDetail.Type.BUYER_CANCEL)){
return dealBuyerCancel(info,sellerWalletDetail);//买家付款后取消订单
}
if(curType.equals(SellerWalletDetail.Type.SYSTEM_OFFSHELF)){
return dealSystemOffShelf(info,sellerWalletDetail);//系统下架商品
}
if(curType.equals(SellerWalletDetail.Type.SELLER_QUIT)){
return dealSellerQuit(info,sellerWalletDetail);//卖家退出入驻
}
return info;
}
private MerchantOrderAttachInfo dealReCharge(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
if(info.getPayment()!=null){
info.setRechargeType(1==info.getPayment().intValue()?"支付宝":"微信");//充值方式
}
info.setSeriNo(info.getOrderCode()==null?null:info.getOrderCode().toString());//充值流水
info.setRechargeTime(info.getTime());//充值时间
info.setRechargeMoney(sellerWalletDetail.getAmount());//充值金额
return info;
}
private MerchantOrderAttachInfo dealSellerOnShelf(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
info.setOnShelfTime(info.getTime());
info.setLockEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().abs().toString());
initProductInfo(info);
return info;
}
private void initProductInfo(MerchantOrderAttachInfo info){
//根据orderCode查商品信息
info.setProductCount(info.getProductCount()==null?1:info.getProductCount());
StorageProductBo bo = initStorageProduct(info);
if(null == bo || bo.getProduct()==null || bo.getStorage() == null){
LOGGER.info("dealSellerOnShelf StorageProductBo is null!StorageProductBo is {},MerchantOrderAttachInfo is {}",bo,info);
return ;
}
info.setProductName(bo.getProduct().getProductName());
info.setSkup(bo.getProduct().getSkup());
List<Goods> goodsList = goodsMapper.selectByProductId(Arrays.asList(bo.getProduct().getId()));
if(!CollectionUtils.isEmpty(goodsList)){
info.setProductColor(goodsList.get(0).getGoodsName());
}
Size size = null;
if(bo.getStorage().getSizeId()!=null &&(size = ufoSizeMapper.selectOneById(bo.getStorage().getSizeId()))!=null){
info.setProductSize(size.getSizeName());
}
}
private StorageProductBo initStorageProduct(MerchantOrderAttachInfo info){
if(null != info.getStorageId()){
Storage storage = storageMapper.selectByPrimaryKey(info.getStorageId());
if(storage!=null){
Product product = null != storage.getProductId()?productMapper.selectByPrimaryKey(storage.getProductId()):null;
return new StorageProductBo(storage,product);
}
}
if(info.getSkup()!=null){
StoragePrice storagePrice = storagePriceMapper.selectBySkup(info.getSkup());
Storage storage = storageMapper.selectByPrimaryKey(storagePrice.getStorageId());
Product product = productMapper.selectByPrimaryKey(storagePrice.getProductId());
return new StorageProductBo(storage,product);
}
return null;
}
private MerchantOrderAttachInfo dealSellerOffShelf(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
info.setUnShelfTime(info.getTime());
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().abs().toString());
initProductInfo(info);
return info;
}
private MerchantOrderAttachInfo dealTradeComplete(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
info.setTradeCompleteTime(info.getTime());
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().abs().toString());
initProductInfo(info);
return info;
}
private MerchantOrderAttachInfo dealSellerTradeFailed(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
info.setCancelOrderTime(info.getTime());
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().abs().toString());
initProductInfo(info);
return info;
}
private MerchantOrderAttachInfo dealSellerAddPrice(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
info.setAdjustPriceTime(info.getTime());
info.setBeforeAdjustPrice(info.getBeforeProductPrice()==null?null:info.getBeforeProductPrice().toString());
info.setBeforeAdjustLockMoney(info.getBeforeEarnestMoney());
info.setAfterAdjustPrice(info.getAfterProductPrice()==null?null:info.getAfterProductPrice().toString());
info.setAfterAdjustLockMoney((info.getAfterEarnestMoney()));
if(info.getAfterAdjustLockMoney()!=null && info.getBeforeAdjustLockMoney()!=null){
BigDecimal afterLockMoney = new BigDecimal(info.getAfterAdjustLockMoney());
info.setAddLockEarnestMoney(afterLockMoney.subtract(new BigDecimal(info.getBeforeAdjustLockMoney())).abs().toString());
}
initProductInfo(info);
return info;
}
private MerchantOrderAttachInfo dealSellerReducePrice(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
info.setAdjustPriceTime(info.getTime());
info.setBeforeAdjustPrice(info.getBeforeProductPrice()==null?null:info.getBeforeProductPrice().toString());
info.setBeforeAdjustLockMoney(info.getBeforeEarnestMoney());
info.setAfterAdjustPrice(info.getAfterProductPrice()==null?null:info.getAfterProductPrice().toString());
info.setAfterAdjustLockMoney((info.getAfterEarnestMoney()));
if(info.getAfterAdjustLockMoney()!=null && info.getBeforeAdjustLockMoney()!=null){
BigDecimal afterLockMoney = new BigDecimal(info.getAfterAdjustLockMoney());
info.setReduceLockEarnestMoney(afterLockMoney.subtract(new BigDecimal(info.getBeforeAdjustLockMoney())).abs().toString());
}
initProductInfo(info);
return info;
}
private MerchantOrderAttachInfo dealBuyerCancel(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
info.setBuyerCancelTime(info.getTime());
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().toString());
initProductInfo(info);
return info;
}
private MerchantOrderAttachInfo dealSystemOffShelf(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
info.setUnShelfTime(info.getTime());
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().toString());
initProductInfo(info);
return info;
}
private MerchantOrderAttachInfo dealSellerQuit(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
info.setRefundSeriNo(null == info.getOrderCode()?null:info.getOrderCode().toString());
info.setRefundTime(info.getTime());
info.setRefundType(1==info.getPayment().intValue()?"支付宝":"微信");
info.setRefundMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().toString());
return info;
}
public PageResponseBO<MerchantOrderAttachInfo> earnestList(MerchantReq req) {
Integer stratTime = parse(req.getStartTime());
Integer endTime = parse(req.getEndTime());
int total = mapper.selectMerchantInfoCount(req.getUid(), stratTime, endTime, req.getStateList());
List<Integer> uids = null;
if(StringUtils.isNotBlank(req.getMerchantName()) || req.getUid() !=null){
uids = storedSellerMapper.selectUidByCertNameAndUid(req.getMerchantName(),req.getUid());
if(CollectionUtils.isEmpty(uids)){
return new PageResponseBO<>();
}
}
int total = mapper.selectMerchantInfoCount(CollectionUtils.isEmpty(uids)?null:uids, stratTime, endTime, req.getStateList(),req.getOrderCode());
if(total == 0) {
return new PageResponseBO<>();
}
List<SellerWalletDetail> beanList = mapper.selectMerchantInfo(req.getUid(), stratTime, endTime, req.getStateList(), req.getStart(), req.getRows());
List<MerchantOrderAttachInfo> boList = new ArrayList<>();
List<SellerWalletDetail> beanList = mapper.selectMerchantInfo(CollectionUtils.isEmpty(uids)?null:uids, stratTime, endTime, req.getStateList(),req.getOrderCode(), req.getStart(), req.getRows());
Map<Integer,Map<String,Object>> storedSellerMap = this.storedSellerMapper.selectNameByUids(beanList.stream().map(cell->cell.getUid()).collect(Collectors.toList()));
List<MerchantOrderAttachInfo> boList = new ArrayList<>();
for(SellerWalletDetail detail : beanList) {
boList.add(exchange(detail));
MerchantOrderAttachInfo info = JSON.parseObject(detail.getAttachValue(), MerchantOrderAttachInfo.class);
info=info == null?new MerchantOrderAttachInfo():info;
info.setOrderCode(detail.getOrderCode());
info.setTime(sdf.get().format(new Date(detail.getCreateTime() * 1000L)));
info.setMerchantName((String)storedSellerMap.get(detail.getUid()).get("cert_name"));
info.setUid(detail.getUid());
boList.add(info);
}
PageResponseBO<MerchantOrderAttachInfo> result=new PageResponseBO<>();
result.setList(boList);
result.setPage(req.getPage());
result.setSize(req.getSize());
result.setTotal(total);
return result;
}
... ... @@ -99,4 +298,43 @@ public class MerchantServiceImpl {
}
}
public PageResponseBO<MerchantOrderAttachInfo> listSellerWallets(MerchantReq req) {
List<Integer> uids = null;
if(StringUtils.isNotBlank(req.getMerchantName())){
uids = storedSellerMapper.selectUidByCertName(req.getMerchantName());
if(CollectionUtils.isEmpty(uids)){
return new PageResponseBO<>();
}
}
int total = this.sellerWalletMapper.selectTotalByUidAndMerchantUids(req.getUid(),uids);
if(total == 0){
return new PageResponseBO<>();
}
List<SellerWallet> sellerWallets = this.sellerWalletMapper.selectByUidAndMerchantUids(req.getUid(),uids,req.getStart(),req.getSize());
List<MerchantOrderAttachInfo> infos = initMerchantOrderAttachInfos(sellerWallets);
PageResponseBO<MerchantOrderAttachInfo> result = new PageResponseBO<>();
result.setTotal(total);
result.setList(infos);
result.setPage(req.getPage());
result.setSize(req.getSize());
return result;
}
private List<MerchantOrderAttachInfo> initMerchantOrderAttachInfos(List<SellerWallet> sellerWallets) {
List<MerchantOrderAttachInfo> infos = new ArrayList<>();
Map<Integer,Map<String,Object>> storedSellerMap = this.storedSellerMapper.selectNameByUids(sellerWallets.stream().map(cell->cell.getUid()).collect(Collectors.toList()));
for (SellerWallet sellerWallet : sellerWallets) {
MerchantOrderAttachInfo info = new MerchantOrderAttachInfo();
BigDecimal amount = sellerWallet.getAmount();
BigDecimal lockMoney = sellerWallet.getLockAmount();
info.setId(sellerWallet.getId());
info.setAccountAmount(null == amount?null:amount.toString());
info.setLockEarnestMoney(null == lockMoney?null:lockMoney.toString());
info.setAvailEarnestMoney(null == amount?null:null == lockMoney?amount.toString():amount.subtract(sellerWallet.getLockAmount()).toString());
info.setUid(sellerWallet.getUid());
info.setMerchantName((String)storedSellerMap.get(sellerWallet.getUid()).get("cert_name"));
infos.add(info);
}
return infos;
}
}
... ...
... ... @@ -34,7 +34,7 @@ datasources:
- com.yoho.order.dal.TradeBillsMapper
- com.yoho.order.dal.StoredSellerMapper
- com.yoho.order.dal.SellerWalletDetailMapper
- com.yoho.order.dal.SellerWalletMapper
ufo_resource:
servers:
- 192.168.102.219:3306
... ...
... ... @@ -34,7 +34,7 @@ datasources:
- com.yoho.order.dal.TradeBillsMapper
- com.yoho.order.dal.StoredSellerMapper
- com.yoho.order.dal.SellerWalletDetailMapper
- com.yoho.order.dal.SellerWalletMapper
ufo_resource:
servers:
- ${jdbc.mysql.ufo.master}
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
<script src="/ufoPlatform/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 230px">
<script>
document.write(addHead('商家管理 /保证金明细', ''));
</script>
<div style="margin-left: 30px;" class="div_search">
<input id="detailType" type="text">
<input class="easyui-datetimebox" id="startTime" />
<input class="easyui-datetimebox" id="endTime" />
</div>
<div style="margin: 10px 0 0 30px;" class="div_search">
<a id="searchLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">筛选</a>
<a id="searchAllLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">全部</a>
<a id="backLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">返回</a>
</div>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px;height: 660px">
<table id="marginDetailListTable"></table>
</div>
</div>
<div id="dialogDetail" class="easyui-dialog" title="详细信息" style="width: 1000px;height: 150px;">
<table id="marginDetailTable">
</table>
</div>
<script type="text/javascript">
var sysParam = window.location.search.substr(1).split("&");
var marginDetailId;
$(function () {
$("#dialogDetail").dialog({
closed: true,
shadow:true,
modal:true,
onOpen:function(){
$("#marginDetailTable").myDatagrid("load",{id:marginDetailId});
}
});
$("#backLinkButton").click(function(){
window.history.back(-1);
});
$("#startTime").textbox({
prompt: "开始时间"
});
$("#endTime").textbox({
prompt: "结束时间"
});
$("#detailType").combobox({
prompt: "事件类型",
width: 150,
editable : false,
data: [
{"text" : "事件类型", "value" : "-1", "selected": true},
{"text" : "卖家充值保证金", "value" : 1},
{"text" : "卖家上架商品", "value" : 11},
{"text" : "商品交易完成", "value" : 51},
{"text" : "卖家下架商品", "value" : 21},
{"text" : "卖家原因交易失败", "value" : "31,32,33"},
{"text" : "卖家上调价格", "value" : "12"},
{"text" : "卖家下调价格", "value" : "13"},
{"text" : "系统下架商品", "value" : "22"},
{"text" : "买家付款后取消订单", "value" : "41,42"},
{"text" : "卖家退出入驻", "value" : 61}
]
});
$("#marginDetailTable").myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
url: contextPath + "/merchant/earnestDetail",
method: 'POST',
showHeader:false,
loadFilter: function (data) {
if (!data || data.code != 200) {
var result={total:0,rows:[] };
return result;
}
var result={total:1,rows:[data.data] };
return result;
var result=[data.data];
result.rows=[data.data];
return result;
},columns:[[
{field:'title',title:'标题',width:100,styler: function(){
return 'font-weight:bold;';
}},
{field:'content',title:'内容',width:100},
{field:'title2',title:'标题2',width:100,styler: function(){
return 'font-weight:bold;';
}},
{field:'content2',title:'内容2',width:100},
{field:'title3',title:'标题3',width:100,styler: function(){
return 'font-weight:bold;';
}},
{field:'content3',title:'内容3',width:100}
]],onLoadSuccess:function(result){
if(result==null||result.rows==null||result.rows.length==0){
return;
}
var data = result.rows[0]
// var type=data.rows[0].type;
// var arr={'uid':'商家UID',seriNo':[1],'rechargeTime':[1],'rechargeMoney':[1],'rechargeType':[1]
// ,'productName':[11,51,21,31,32,33,12,13,22,41,42],'productPrice':[11,51,21,31,32,33,12,13,22,41,42],
// 'skup':[11,51,21,31,32,33,12,13,22,41,42],
// 'productColor':[11,51,21,31,32,33,12,13,22,41,42],'productCount':[11,51,21,31,32,33,12,13,22,41,42],
// 'productSize':[11,51,21,31,32,33,12,13,22,41,42],'onShelfTime':[11]
// ,'lockEarnestMoney':[11],'tradeCompleteTime':[51],'releaseEarnestMoney':[51,21,31,32,33,41,42,22],
// 'orderCode':[51,31,32,33,41,42],'unShelfTime':[21,22],'adjustPriceTime':[12,13]
// ,'addLockEarnestMoney':[12],'reduceLockEarnestMoney':[13],'beforeAdjustPrice':[12,13],
// 'beforeAdjustLockMoney':[12,13],'afterAdjustPrice':[12,13]
// ,'afterAdjustLockMoney':[12,13],'buyerCancelTime':[41,42],'refundTime':[61],'refundSeriNo':[61],
// 'refundType':[61],'refundMoney':[61],'cancelOrderTime':[41,42]};
// for(var key in arr){
// var operation = arr[key].indexOf(type)>-1?"showColumn":"hideColumn";
// $("#marginDetailTable").myDatagrid(operation, key);
// }
}});
$("#marginDetailListTable").myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
url: contextPath + "/merchant/earnestList",
method: 'POST',
queryParams:{uid:sysParam[0]},
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "卖家UID",
field: "uid",
width: 40,
align: "center",
rowspan:2
}, {
title: "卖家名称",
field: "userName",
width: 40,
align: "center",
rowspan:2,
formatter: function (value, rowData) {
return decodeURI(sysParam[1]);
}
}, {
title: "时间",
field: "time",
width: 40,
align: "center",
rowspan:2
}, {
title: "事件",
field: "typeName",
width: 40,
align: "center",
rowspan:2
}, {
title: "账户保证金",
width: 80,
align: "center",
colspan:2
}, {
title: "冻结保证金",
width: 80,
align: "center",
colspan:2
}, {
title: "可用额度",
width: 80,
align: "center",
colspan:2
}, {
title: "操作",
field: "operations",
width: 80,
align: "center",
rowspan:2,
formatter: function (value, rowData) {
return "<a role='view' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de'>查看</a>";
}
}],[{
title: "金额",
field: "accountAmount",
width: 40,
align: "center"
},{
title: "账户保证金",
field: "accountAllAmount",
width: 40,
align: "center"
},{
title: "金额",
field: "lockEarnestMoney",
width: 40,
align: "center"
},{
title: "冻结保证金",
field: "lockAllEarnestMoney",
width: 40,
align: "center"
},{
title: "金额",
field: "availEarnestMoney",
width: 40,
align: "center"
},{
title: "可用额度",
field: "availAllEarnestMoney",
width: 40,
align: "center"
}]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function () {
$(this).myDatagrid("getPanel").find("a[role='view']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
marginDetailId=$(this).attr("dataId");
$('#dialogDetail').dialog('open');
}
});
}
});
var pg = $("#marginDetailListTable").datagrid("getPager").pagination({
onRefresh:function(pageNumber,pageSize){
loadData(pageNumber,pageSize)
},
onSelectPage:function(pageNumber,pageSize){
loadData(pageNumber,pageSize)
}
});
// 搜索
$("#searchLinkButton").linkbutton({
onClick: function () {
loadData();
}
});
// 搜索全部
$("#searchAllLinkButton").linkbutton({
onClick: function () {
$("#detailType").textbox("clear");
$("#startTime").textbox("clear");
$("#endTime").textbox("clear");
var param = {uid:sysParam[0]};
$("#marginDetailListTable").myDatagrid("load", param);
}
});
function loadData(pageNumber,pageSize){
var param = {};
param.uid=sysParam[0];
param.startTime = $('#startTime').textbox('getValue');
param.endTime = $('#endTime').textbox('getValue');
var stateList = $('#detailType').combobox('getValue').split(",");
param.stateList = stateList[0]==-1?null:stateList;
if(pageNumber){
param.page=pageNumber;
}
if(pageSize){
param.size=pageSize;
}
param = $.param(param, true);
$.post(contextPath + "/merchant/earnestList",param,function (data) {
$("#marginDetailListTable").myDatagrid('loadData', data); //本地加载
});
}
});
</script>
</body>
</html>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
<script src="/ufoPlatform/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 230px">
<script>
document.write(addHead('商家管理 /商家保证金', ''));
</script>
<div style="margin-left: 30px;" class="div_search">
<input id="uid" type="text">
<input id="merchantName" type="text"/>
</div>
<div style="margin: 10px 0 0 30px;" class="div_search">
<a id="searchLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">筛选</a>
<a id="searchAllLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">全部</a>
</div>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px;height: 660px">
<table id="marginTable"></table>
</div>
</div>
<script type="text/javascript">
var brandSeriesId;
$(function () {
$("#uid").textbox({
prompt: "用户UID"
});
$("#merchantName").textbox({
prompt: "商家名称"
});
$("#marginTable").myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
url: contextPath + "/merchant/listSellerWallets",
method: 'POST',
queryParams:{
uid : $('#uid').textbox('getValue'),
merchantName : $('#merchantName').textbox('getText')
},
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "UID",
field: "uid",
width: 40,
align: "center"
}, {
title: "商家名称",
field: "merchantName",
width: 80,
align: "center"
}, {
title: "账户保证金",
field: "accountAmount",
width: 100,
align: "center"
}, {
title: "冻结保证金",
field: "lockEarnestMoney",
width: 80,
align: "center"
}, {
title: "可用保证金",
field: "availEarnestMoney",
width: 80,
align: "center",
}, {
title: "操作",
field: "operations",
width: 80,
align: "center",
formatter: function (value, rowData) {
return "<a role='view' dataId='" + rowData.uid + "' dataName='" + rowData.merchantName + "' style='margin-left:10px;background-color: #5bc0de'>查看</a>";
}
}]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function () {
// 编辑
$(this).myDatagrid("getPanel").find("a[role='view']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
var id = $(this).attr("dataId");
var userName=$(this).attr("dataName");
window.location.href = contextPath + "/html/merchantManage/margin/marginDetailList.html?" + id+"&"+userName;
}
});
}
});
// 搜索
$("#searchLinkButton").linkbutton({
onClick: function () {
var param = {};
param.uid = $('#uid').textbox('getValue');
param.merchantName = $('#merchantName').textbox('getText');
$("#marginTable").myDatagrid("load", param);
}
});
// 搜索全部
$("#searchAllLinkButton").linkbutton({
onClick: function () {
$('#uid').textbox("clear");
$('#merchantName').textbox("clear");
var param = {};
$("#marginTable").myDatagrid("load", param);
}
});
});
</script>
</body>
</html>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
<script src="/ufoPlatform/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 230px">
<script>
document.write(addHead('商家管理 /违规记录', ''));
</script>
<div style="margin-left: 30px;" class="div_search">
<input id="uid" type="text">
<input id="merchantName" type="text"/>
<input id="orderCode" type="text"/>
<input id="violationType" type="text">
</div>
<div style="margin: 10px 0 0 30px;" class="div_search">
<a id="searchLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">筛选</a>
<a id="searchAllLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">全部</a>
</div>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px;height: 660px">
<table id="marginTable"></table>
</div>
</div>
<script type="text/javascript">
$(function () {
$("#uid").textbox({
prompt: "用户UID"
});
$("#merchantName").textbox({
prompt: "商家名称"
});
$("#orderCode").textbox({
prompt: "订单编号"
});
$("#violationType").combobox({
prompt: "违规类型",
width: 150,
editable : false,
data: [
{"text" : "违规类型", "value" : "32,33", "selected": true},
{"text" : "超时未发货", "value" : 32},
{"text" : "鉴定不通过", "value" : 33},
]
});
$("#marginTable").myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "UID",
field: "uid",
width: 80,
align: "center"
}, {
title: "商家名称",
field: "merchantName",
width: 120,
align: "center"
}, {
title: "违规时间",
field: "time",
width: 120,
align: "center"
}, {
title: "违规订单",
field: "orderCode",
width: 120,
align: "center"
}, {
title: "违规类型",
field: "typeName",
width: 120,
align: "center",
}]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false
});
var pg = $("#marginTable").datagrid("getPager").pagination({
onRefresh:function(pageNumber,pageSize){
loadData(pageNumber,pageSize)
},
onSelectPage:function(pageNumber,pageSize){
loadData(pageNumber,pageSize)
}
});
// 搜索
$("#searchLinkButton").linkbutton({
onClick: function () {
loadData();
}
});
// 搜索全部
$("#searchAllLinkButton").linkbutton({
onClick: function () {
$("#uid").textbox("clear");
$("#merchantName").textbox("clear");
$("#orderCode").textbox("clear");
$("#violationType").textbox("clear");
loadData();
}
});
loadData();
function loadData(pageNumber,pageSize){
var param = {};
param.uid = $('#uid').textbox('getValue');
param.merchantName = $('#merchantName').textbox('getText');
param.orderCode = $('#orderCode').textbox('getValue');
var stateList = $('#violationType').combobox('getValue').split(",");
param.stateList = stateList[0] == ""?[32,33]:stateList;
if(pageNumber){
param.page=pageNumber;
}
if(pageSize){
param.size=pageSize;
}
param = $.param(param, true);
$.post(contextPath + "/merchant/earnestList",param,function (data) {
$("#marginTable").myDatagrid('loadData', data); //本地加载
});
}
});
</script>
</body>
</html>
\ No newline at end of file
... ...