Authored by wujiexiang

Merge branch 'dev_order' into dev-promotion

# Conflicts:
#	order/src/main/java/com/yohoufo/order/model/request/ShoppingRequest.java
Showing 53 changed files with 2424 additions and 255 deletions
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.EntrySellerRechargeOrder;
public interface EntrySellerRechargeOrderMapper {
int deleteByPrimaryKey(Integer id);
int insert(EntrySellerRechargeOrder record);
int insertSelective(EntrySellerRechargeOrder record);
EntrySellerRechargeOrder selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(EntrySellerRechargeOrder record);
int updateByPrimaryKey(EntrySellerRechargeOrder record);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.MachineIdGenerate;
import java.util.List;
public interface MachineIdGenerateMapper {
int deleteByPrimaryKey(Integer id);
int insert(MachineIdGenerate record);
int insertSelective(MachineIdGenerate record);
MachineIdGenerate selectByPrimaryKey(Integer id);
MachineIdGenerate selectByIp(String ip);
List<MachineIdGenerate> selectByAll();
int updateByPrimaryKeySelective(MachineIdGenerate record);
int updateByPrimaryKey(MachineIdGenerate record);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.SellerWalletDetail;
public interface SellerWalletDetailMapper {
int deleteByPrimaryKey(Integer id);
int insert(SellerWalletDetail record);
int insertSelective(SellerWalletDetail record);
SellerWalletDetail selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SellerWalletDetail record);
int updateByPrimaryKey(SellerWalletDetail record);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.SellerWallet;
public interface SellerWalletMapper {
int insert(SellerWallet record);
int insertSelective(SellerWallet record);
SellerWallet selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SellerWallet record);
int updateByPrimaryKey(SellerWallet record);
SellerWallet selectByUidNType(SellerWallet condition);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.SkupBatch;
public interface SkupBatchMapper {
int deleteByPrimaryKey(Long id);
int insert(SkupBatch record);
int insertSelective(SkupBatch record);
SkupBatch selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(SkupBatch record);
int updateByPrimaryKey(SkupBatch record);
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
import java.math.BigDecimal;
public class EntrySellerRechargeOrder {
private Integer id;
private Integer uid;
private Long orderCode;
private Integer payment;
private Integer status;
private BigDecimal amount;
private Integer type;
private Integer createTime;
private Integer updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public Long getOrderCode() {
return orderCode;
}
public void setOrderCode(Long orderCode) {
this.orderCode = orderCode;
}
public Integer getPayment() {
return payment;
}
public void setPayment(Integer payment) {
this.payment = payment;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
public class MachineIdGenerate {
private Integer id;
private String ip;
private Integer machineId;
private Integer createTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip == null ? null : ip.trim();
}
public Integer getMachineId() {
return machineId;
}
public void setMachineId(Integer machineId) {
this.machineId = machineId;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
import java.math.BigDecimal;
public class SellerWallet {
private Integer id;
private Integer uid;
private BigDecimal amount;
private Byte status;
private Byte type;
private Integer createTime;
private Integer updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public Byte getStatus() {
return status;
}
public void setStatus(Byte status) {
this.status = status;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
import java.math.BigDecimal;
public class SellerWalletDetail {
private Integer id;
private Integer walletId;
private Integer uid;
private Long orderCode;
private BigDecimal amount;
private Byte type;
private Integer createTime;
private Integer updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getWalletId() {
return walletId;
}
public void setWalletId(Integer walletId) {
this.walletId = walletId;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public Long getOrderCode() {
return orderCode;
}
public void setOrderCode(Long orderCode) {
this.orderCode = orderCode;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
... ...
package com.yohoufo.dal.order.model;
public class SkupBatch {
private Long id;
private Integer uid;
private Integer num;
private Integer createTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
... ...
... ... @@ -24,4 +24,6 @@ public interface StorageMapper {
int addStorageNum(@Param("storageId")Integer storageId, @Param("storageNum")Integer storageNum);
List<Storage> selectByGoodsId(Integer goodsId);
int batchAddStorageNum(@Param("storageList")List<Storage> storageList);
}
\ No newline at end of file
... ...
... ... @@ -10,6 +10,8 @@ public interface StoragePriceMapper {
int deleteByPrimaryKey(Integer id);
int insert(StoragePrice record);
int insertBatch(@Param("storagePriceList")List<StoragePrice> storagePriceList);
StoragePrice selectByPrimaryKey(Integer id);
... ... @@ -25,9 +27,13 @@ public interface StoragePriceMapper {
int updateStatus(@Param("skup")Integer skup, @Param("status")Integer status, @Param("beforeStatus")Integer beforeStatus);
int batchUpdateStatus(@Param("skupList")List<Integer> skupList, @Param("status")Integer status);
int updateDepotNum(@Param("skup")Integer skup, @Param("depotNum")Integer depotNum);
StoragePrice selectLeastPrice(Integer storageId);
List<StoragePrice> selectByStorageIds(List<Integer> storageIds);
List<StoragePrice> selectBySkupList(@Param("skupList")List<Integer> skupList);
}
\ No newline at end of file
... ...
<?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.yohoufo.dal.order.EntrySellerRechargeOrderMapper" >
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.EntrySellerRechargeOrder" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="BIGINT" />
<result column="payment" property="payment" jdbcType="TINYINT" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="amount" property="amount" jdbcType="DECIMAL" />
<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, order_code, payment, status, amount, type, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from entry_seller_recharge_order
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from entry_seller_recharge_order
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.EntrySellerRechargeOrder" >
insert into entry_seller_recharge_order (id, uid, order_code,
payment, status, amount,
type, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT},
#{payment,jdbcType=TINYINT}, #{status,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL},
#{type,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.EntrySellerRechargeOrder" >
insert into entry_seller_recharge_order
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="uid != null" >
uid,
</if>
<if test="orderCode != null" >
order_code,
</if>
<if test="payment != null" >
payment,
</if>
<if test="status != null" >
status,
</if>
<if test="amount != null" >
amount,
</if>
<if test="type != null" >
type,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="uid != null" >
#{uid,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
#{orderCode,jdbcType=BIGINT},
</if>
<if test="payment != null" >
#{payment,jdbcType=TINYINT},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
<if test="amount != null" >
#{amount,jdbcType=DECIMAL},
</if>
<if test="type != null" >
#{type,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.EntrySellerRechargeOrder" >
update entry_seller_recharge_order
<set >
<if test="uid != null" >
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
order_code = #{orderCode,jdbcType=BIGINT},
</if>
<if test="payment != null" >
payment = #{payment,jdbcType=TINYINT},
</if>
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
</if>
<if test="amount != null" >
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="type != null" >
type = #{type,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.EntrySellerRechargeOrder" >
update entry_seller_recharge_order
set uid = #{uid,jdbcType=INTEGER},
order_code = #{orderCode,jdbcType=BIGINT},
payment = #{payment,jdbcType=TINYINT},
status = #{status,jdbcType=TINYINT},
amount = #{amount,jdbcType=DECIMAL},
type = #{type,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
<?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.yohoufo.dal.order.MachineIdGenerateMapper" >
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.MachineIdGenerate" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="ip" property="ip" jdbcType="VARCHAR" />
<result column="machine_id" property="machineId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, ip, machine_id, create_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from machine_id_generate
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByIp" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from machine_id_generate
where ip = #{ip,jdbcType=VARCHAR}
</select>
<select id="selectByAll" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from machine_id_generate
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from machine_id_generate
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.MachineIdGenerate" >
insert into machine_id_generate (id, ip, machine_id,
create_time)
values (#{id,jdbcType=INTEGER}, #{ip,jdbcType=VARCHAR}, #{machineId,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.MachineIdGenerate" >
insert into machine_id_generate
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="ip != null" >
ip,
</if>
<if test="machineId != null" >
machine_id,
</if>
<if test="createTime != null" >
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="ip != null" >
#{ip,jdbcType=VARCHAR},
</if>
<if test="machineId != null" >
#{machineId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.MachineIdGenerate" >
update machine_id_generate
<set >
<if test="ip != null" >
ip = #{ip,jdbcType=VARCHAR},
</if>
<if test="machineId != null" >
machine_id = #{machineId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.MachineIdGenerate" >
update machine_id_generate
set ip = #{ip,jdbcType=VARCHAR},
machine_id = #{machineId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
<?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.yohoufo.dal.order.SellerWalletDetailMapper" >
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.SellerWalletDetail" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="wallet_id" property="walletId" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="BIGINT" />
<result column="amount" property="amount" jdbcType="DECIMAL" />
<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, wallet_id, uid, order_code, amount, type, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from seller_wallet_detail
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from seller_wallet_detail
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.SellerWalletDetail" >
insert into seller_wallet_detail (id, wallet_id, uid,
order_code, amount, type,
create_time, update_time)
values (#{id,jdbcType=INTEGER}, #{walletId,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER},
#{orderCode,jdbcType=BIGINT}, #{amount,jdbcType=DECIMAL}, #{type,jdbcType=TINYINT},
#{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.SellerWalletDetail" >
insert into seller_wallet_detail
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="walletId != null" >
wallet_id,
</if>
<if test="uid != null" >
uid,
</if>
<if test="orderCode != null" >
order_code,
</if>
<if test="amount != null" >
amount,
</if>
<if test="type != null" >
type,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="walletId != null" >
#{walletId,jdbcType=INTEGER},
</if>
<if test="uid != null" >
#{uid,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
#{orderCode,jdbcType=BIGINT},
</if>
<if test="amount != null" >
#{amount,jdbcType=DECIMAL},
</if>
<if test="type != null" >
#{type,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.SellerWalletDetail" >
update seller_wallet_detail
<set >
<if test="walletId != null" >
wallet_id = #{walletId,jdbcType=INTEGER},
</if>
<if test="uid != null" >
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
order_code = #{orderCode,jdbcType=BIGINT},
</if>
<if test="amount != null" >
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="type != null" >
type = #{type,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.SellerWalletDetail" >
update seller_wallet_detail
set wallet_id = #{walletId,jdbcType=INTEGER},
uid = #{uid,jdbcType=INTEGER},
order_code = #{orderCode,jdbcType=BIGINT},
amount = #{amount,jdbcType=DECIMAL},
type = #{type,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
<?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.yohoufo.dal.order.SellerWalletMapper" >
<resultMap id="BaseResultMap" type="com.yohoufo.dal.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="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, status, type, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from seller_wallet
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByUidNType" resultMap="BaseResultMap" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
select
<include refid="Base_Column_List" />
from seller_wallet
where uid = #{uid,jdbcType=INTEGER} and `type` = #{type,jdbcType=TINYINT} limit 1
</select>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
insert into seller_wallet (id, uid, amount,
status, type, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL},
#{status,jdbcType=TINYINT}, #{type,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER},
#{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
insert into seller_wallet
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="uid != null" >
uid,
</if>
<if test="amount != null" >
amount,
</if>
<if test="status != null" >
status,
</if>
<if test="type != null" >
type,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="uid != null" >
#{uid,jdbcType=INTEGER},
</if>
<if test="amount != null" >
#{amount,jdbcType=DECIMAL},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
<if test="type != null" >
#{type,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
update seller_wallet
<set >
<if test="uid != null" >
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="amount != null" >
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
</if>
<if test="type != null" >
type = #{type,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.SellerWallet" >
update seller_wallet
set uid = #{uid,jdbcType=INTEGER},
amount = #{amount,jdbcType=DECIMAL},
status = #{status,jdbcType=TINYINT},
type = #{type,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
<?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.yohoufo.dal.order.SkupBatchMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.SkupBatch">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="num" jdbcType="INTEGER" property="num" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, uid, num, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from skup_batch
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from skup_batch
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.SkupBatch" useGeneratedKeys="true">
insert into skup_batch (uid, num, create_time
)
values (#{uid,jdbcType=INTEGER}, #{num,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.SkupBatch" useGeneratedKeys="true">
insert into skup_batch
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="uid != null">
uid,
</if>
<if test="num != null">
num,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="uid != null">
#{uid,jdbcType=INTEGER},
</if>
<if test="num != null">
#{num,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.SkupBatch">
update skup_batch
<set>
<if test="uid != null">
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="num != null">
num = #{num,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.SkupBatch">
update skup_batch
set uid = #{uid,jdbcType=INTEGER},
num = #{num,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -49,9 +49,12 @@
#{tradeStatus},#{createTime},#{dealUid},#{dealStatus},#{dealTime},#{dealRelateId},#{dealUserName})
</insert>
<!-- 买家只显示补偿款收入 ,卖家只显示货款收入 -->
<!-- 买家只显示补偿款收入 ,卖家只显示货款收入
modify by craig.qin 20181109 : 卖家除了显示货款收入,还要显示卖家的补偿款收入
-->
<sql id="Query_Condition_Sql" >
uid = #{uid,jdbcType=INTEGER} and income_outcome = 1 and ( (user_type =1 and trade_type = 3) or (user_type =2 and trade_type = 2) ) and (trade_status = 100 or (trade_status != 100 and deal_status !=1 ))
uid = #{uid,jdbcType=INTEGER} and income_outcome = 1 and deal_status != 1
and ( (user_type =1 and trade_type = 3) or (user_type =2 and trade_type = 2) or (user_type =2 and trade_type = 3) )
</sql>
<select id="selectCountGoodsIncomeOrCompensateIncomeByUid" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
... ...
... ... @@ -62,5 +62,25 @@
update_time = unix_timestamp()
where id = #{storageId,jdbcType=INTEGER}
</update>
<update id="batchAddStorageNum" parameterType="java.util.List">
update storage
<trim prefix="set" suffixOverrides=",">
<trim prefix="storage_num =case" suffix="end,">
<foreach collection="storageList" item="item" index="index">
<if test="item.storageNum!=null">
when id=#{item.id,jdbcType=INTEGER} then storage_num + #{item.storageNum,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="update_time =case" suffix="end,">
<foreach collection="storageList" item="item" index="index">
when id=#{item.id,jdbcType=INTEGER} then unix_timestamp()
</foreach>
</trim>
</trim>
where
<foreach collection="storageList" separator="or" item="item" index="index" >
id= #{item.id,jdbcType=INTEGER}
</foreach>
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -28,6 +28,21 @@
#{price,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER})
</insert>
<insert id="insertBatch">
insert into storage_price (skup, product_id, goods_id,
storage_id, depot_num, seller_uid,
price, status, update_time,
create_time)
values
<foreach collection="storagePriceList" item="item" index="index" separator="," >
(#{item.skup,jdbcType=INTEGER}, #{item.productId,jdbcType=INTEGER},
#{item.goodsId,jdbcType=INTEGER},#{item.storageId,jdbcType=INTEGER}, #{item.depotNum,jdbcType=INTEGER}, #{item.sellerUid,jdbcType=INTEGER},
#{item.price,jdbcType=DECIMAL}, #{item.status,jdbcType=INTEGER}, #{item.updateTime,jdbcType=INTEGER},
#{item.createTime,jdbcType=INTEGER})
</foreach>
</insert>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.product.model.StoragePrice">
update storage_price
set skup = #{skup,jdbcType=INTEGER},
... ... @@ -81,6 +96,16 @@
#{item}
</foreach>
</select>
<select id="selectBySkupList" resultMap="BaseResultMap">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status,
update_time, create_time
from storage_price
where skup in
<foreach item="item" index="index" collection="skupList"
open="(" separator="," close=")">
#{item}
</foreach>
</select>
<update id="updateStatus">
update storage_price set status = #{status,jdbcType=INTEGER},
update_time = unix_timestamp()
... ... @@ -95,5 +120,12 @@
where skup = #{skup,jdbcType=INTEGER}
and status = 100
</update>
<update id="batchUpdateStatus">
update storage_price set status = #{status,jdbcType=INTEGER},
update_time = unix_timestamp()
where skup in
<foreach item="skup" index="index" collection="skupList" open="(" separator="," close=")">
#{skup}
</foreach>
</update>
</mapper>
\ No newline at end of file
... ...
package com.yohoufo.order.common;
import java.util.Map;
/**
* 1:鉴定通过(货款-->卖家 + 平台);
* 2:鉴定不通过(保证金 --> 买家 + 平台);
* 3:有买家时卖家不卖了(保证金 --> 买家+ 平台)
* 4:超时发货(保证金 --> 买家 + 平台)
* Created by chenchao on 2018/10/9.
* 5:买家付款后[卖家未发货],取消订单(货款部分-->卖家);
* 6:买家付款后[卖家已发货],取消订单(货款部分-->卖家);
*/
public enum TransferCase {
... ... @@ -13,7 +17,9 @@ public enum TransferCase {
APPRAISE_SUCCESS(1),
APPRAISE_FAIL(2),
SELLER_PLAY_BUYER(3),
DELIVER_TIME_OUT(4);
DELIVER_TIME_OUT(4),
BUYER_CANCEL_BEFORE_SELLER_DELIVER(5),
BUYER_CANCEL_BEFORE_DEPOT_RECEIVE(6);
private int code;
... ... @@ -24,4 +30,16 @@ public enum TransferCase {
public int getCode() {
return code;
}
private static Map<Integer, TransferCase> cache;
static {
for(TransferCase tc: values()){
cache.put(tc.code, tc);
}
}
public static TransferCase getTransferCase(Integer code){
return cache.get(code);
}
}
... ...
package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.req.SellerOrderCancelReq;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohobuy.ufo.model.order.req.*;
import com.yohobuy.ufo.model.order.resp.BatchChangePriceResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
... ... @@ -11,7 +10,6 @@ import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
import com.yohoufo.order.service.impl.SellerOrderCancelService;
import com.yohoufo.order.service.impl.SellerOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -34,6 +32,9 @@ public class SellerOrderController {
@Autowired
private SellerOrderService sellerOrderService;
@Autowired
private SellerOrderComputeHandler sellerOrderComputeHandler;
/**
* 根据卖家提交价格来计算各项费用
* @param uid
... ... @@ -46,8 +47,10 @@ public class SellerOrderController {
@ResponseBody
public ApiResponse computePublishPrd(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "storage_id", required = true)int storage_id,
@RequestParam(name="price", required = true)String price) throws GatewayException {
SellerOrderComputeReq req = SellerOrderComputeReq.builder().uid(uid).storageId(storage_id).price(price).build();
@RequestParam(name="price", required = true)String price,
@RequestParam(name="num", defaultValue = "1", required = false)int num) throws GatewayException {
SellerOrderComputeReq req = SellerOrderComputeReq.builder().uid(uid).storageId(storage_id).price(price)
.num(num).build();
logger.info("in ufo.sellerOrder.computePublishPrd, req {}", req);
SoldPrdComputeBo computeBo = sellerOrderService.computePublishPrd(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(computeBo).message("算费成功").build();
... ... @@ -68,7 +71,8 @@ public class SellerOrderController {
public ApiResponse publishPrd(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "storage_id", required = true)int storage_id,
@RequestParam(name="price", required = true)String price,
@RequestParam(name="address_id")String address_id) throws GatewayException {
@RequestParam(name="address_id")String address_id,
@RequestParam(name="num", defaultValue = "1", required = false)int num) throws GatewayException {
SellerOrderSubmitReq req = SellerOrderSubmitReq.builder()
.uid(uid)
.storageId(storage_id)
... ... @@ -80,7 +84,33 @@ public class SellerOrderController {
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("发布成功").build();
}
/**
* 入驻商家的批量下架
* @param uid
* @param batchNo
* @param num
* @return
* @throws GatewayException
*/
@RequestMapping(params = "method=ufo.sellerOrder.batchCancel")
@ResponseBody
public ApiResponse batchCancel(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "batchNo", required = true)String batchNo,
@RequestParam(name="num", defaultValue = "1", required = false)int num,
@RequestParam(name = "skupList", required = true)String skupList
) throws GatewayException {
SellerOrderBatchCancelReq req = SellerOrderBatchCancelReq.builder()
.uid(uid).batchNo(batchNo).storageNum(num).skupList(skupList)
.build();
logger.info("in ufo.sellerOrder.batchCancel, req {}", req);
boolean result = sellerOrderService.batchCancel(req);
String msg = "批量取消成功";
if(!result){
msg = "批量取消失败";
}
return new ApiResponse.ApiResponseBuilder().data(result).code(200).message(msg).build();
}
... ... @@ -144,8 +174,7 @@ public class SellerOrderController {
return new ApiResponse.ApiResponseBuilder().data(result).code(200).message(msg).build();
}
@Autowired
private SellerOrderComputeHandler sellerOrderComputeHandler;
@RequestMapping(params = "method=ufo.skup.earnestMoneyRange")
@ResponseBody
... ... @@ -154,4 +183,31 @@ public class SellerOrderController {
.data(sellerOrderComputeHandler.getEarnestMoneyrange())
.message("get EarnestMoneyrange success").build();
}
/**
* 批量调价
* @param uid
* @param batchNo
* @param price
* @return
* @throws GatewayException
*/
@RequestMapping(params = "method=ufo.sellerOrder.batchChangePrice")
@ResponseBody
public ApiResponse batchChangePrice(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "price", required = true)String price,
@RequestParam(name = "batchNo", required = true)String batchNo,
@RequestParam(name = "skupList", required = true)String skupList
) throws GatewayException {
BatchChangePriceReq req = BatchChangePriceReq.builder()
.uid(uid).price(price)
.batchNo(batchNo).skupList(skupList)
.build();
logger.info("in ufo.sellerOrder.batchChangePrice, req {}", req);
BatchChangePriceResp result = sellerOrderService.batchChangePrice(req);
return new ApiResponse.ApiResponseBuilder().data(result).code(200).message(result.getTips()).build();
}
}
... ...
package com.yohoufo.order.event;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
/**
* Created by chao.chen on 2018/11/14.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BeforeDepotReceiveEvent extends Event {
private int buyerUid;
private long orderCode;
private OrderStatus target;
private OrderStatus expected;
private int sellerUid;
private int skup;
}
... ...
package com.yohoufo.order.event;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.alarm.Event;
import lombok.*;
import lombok.experimental.Builder;
/**
* Created by chao.chen on 2018/11/14.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BeforeSellerDeliverEvent extends Event {
private int buyerUid;
private long orderCode;
private OrderStatus target;
private OrderStatus expected;
private int sellerUid;
private int skup;
}
... ...
package com.yohoufo.order.model.request;
import com.yohoufo.order.common.RefundCase;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
... ... @@ -23,6 +24,10 @@ public class PaymentRequest {
* 退款金额
*/
private double refundAmount;
private String amount;
private String openid;
private RefundCase refundCase;
}
... ...
... ... @@ -37,5 +37,7 @@ public class ShoppingRequest {
*/
private String channelNo;
private String amount;
}
... ...
... ... @@ -22,7 +22,10 @@ public class TransferMoneyRequest {
* <pre>
* 1:鉴定通过(货款-->卖家);
* 2:鉴定不通过(保证金 --> 买家);
* 3:有买家时卖家不卖了(保证金 --> 买家)
* 3:有买家时卖家不卖了(保证金 --> 买家);
* // 20181109 add
* 4:买家付款后[卖家未发货],取消订单(货款部分-->卖家);
* 5:买家付款后[卖家已发货],取消订单(货款部分-->卖家);
* </pre>
*/
private int type;
... ...
package com.yohoufo.order.service.handler;
import com.yohoufo.order.service.impl.OrderDynamicConfig;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
/**
* Created by chao.chen on 2018/11/16.
*/
@Component
public class BuyerCancelCompensateComputeHandler {
@Resource(name = "orderDynamicConfig")
OrderDynamicConfig orderDynamicConfig;
public BigDecimal calBeforeSellerDeliver(){
//todo 若后续改成动态配置时,需要实时计算
OrderDynamicConfig.BuyerCancelCompensateNode node = orderDynamicConfig.getBeforeSellerDeliverBCCN();
return node.getSellerGetMoney();
}
public BigDecimal calBeforeDepotReceive(){
//todo 若后续改成动态配置时,需要实时计算
OrderDynamicConfig.BuyerCancelCompensateNode node = orderDynamicConfig.getBeforeDepotReceiveBCCN();
return node.getSellerGetMoney();
}
}
... ...
package com.yohoufo.order.service.impl;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.event.BeforeDepotReceiveEvent;
import com.yohoufo.order.event.BeforeSellerDeliverEvent;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
/**
* Created by chao.chen on 2018/11/13.
*/
@Service
public class BuyerOrderCancelService {
private Logger logger = LoggerUtils.getOrderCloseLogger();
@Resource(name = "orderDynamicConfig")
private OrderDynamicConfig orderDynamicConfig;
@Autowired
private BuyerOrderMapper buyerOrderMapper;
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
public void cancel(BeforeSellerDeliverEvent bsdEvent){
OrderDynamicConfig.BuyerCancelCompensateNode compensate = orderDynamicConfig.getBeforeSellerDeliverBCCN();
logger.info("in buyer cancel BeforeSellerDeliver, event {} compensate {}", bsdEvent, compensate);
int buyerUid = bsdEvent.getBuyerUid();
long orderCode = bsdEvent.getOrderCode();
OrderStatus target = bsdEvent.getTarget();
OrderStatus expected = bsdEvent.getExpected();
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), target.getCode(), currentTime);
if (rows>0) {
int skup = bsdEvent.getSkup();
SellerOrderGoods targetGoods = new SellerOrderGoods();
targetGoods.setId(skup);
targetGoods.setStatus(SkupStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode());
targetGoods.setExceptStatus(SkupStatus.SELL_OUT.getCode());
sellerOrderGoodsMapper.updateStatusBySkpu(targetGoods);
//TODO 整个过程异步去执行(考虑退费依赖订单状态)
//(退费)退保证金给卖家
//(转账)瓜分指定赔偿款给卖家和平台
//(退费)扣除赔偿款,计算剩余的货款,退给买家
}
}
public void cancel(BeforeDepotReceiveEvent bdrEvent){
OrderDynamicConfig.BuyerCancelCompensateNode compensate = orderDynamicConfig.getBeforeDepotReceiveBCCN();
logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, compensate);
OrderStatus target = bdrEvent.getTarget();
OrderStatus expected = bdrEvent.getExpected();
int buyerUid = bdrEvent.getBuyerUid();
long orderCode = bdrEvent.getOrderCode();
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), target.getCode(), currentTime);
if (rows>0) {
int skup = bdrEvent.getSkup();
SellerOrderGoods targetGoods = new SellerOrderGoods();
targetGoods.setId(skup);
targetGoods.setStatus(SkupStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode());
targetGoods.setExceptStatus(SkupStatus.SELL_OUT.getCode());
sellerOrderGoodsMapper.updateStatusBySkpu(targetGoods);
//TODO 整个过程异步去执行(考虑退费依赖订单状态)
//(退费)退保证金给卖家
//(转账)瓜分指定赔偿款给卖家和平台
//(退费)扣除赔偿款,计算剩余的货款,退给买家
}
}
}
... ...
... ... @@ -4,15 +4,14 @@ 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.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.BuyerOrderMetaMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.IOrderListService;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -40,8 +39,6 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
@Autowired
SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
BuyerOrderMetaMapper buyerOrderMetaMapper;
/**
* 根据type获取 指定的状态
* @param request
... ...
... ... @@ -19,6 +19,8 @@ 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.yohoufo.order.event.BeforeDepotReceiveEvent;
import com.yohoufo.order.event.BeforeSellerDeliverEvent;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
... ... @@ -71,6 +73,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
private CacheCleaner cacheCleaner;
@Autowired
private BuyerOrderCancelService buyerOrderCancelService;
/**
* 提交订单
* @param orderRequest
... ... @@ -78,7 +83,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
public void confirm(OrderRequest orderRequest){
OrderStatus expectStatus = OrderStatus.WAITING_RECEIVE;
// 参数检查 ![待收货] 不合法
DataNode node = checkStatusAndRequest(orderRequest, expectStatus);
DataNode node = checkBase(orderRequest);
checkStatus(node,orderRequest, expectStatus);
int uid;
long orderCode;
int sellerUid = node.buyerOrderInDB.getSellerUid();
... ... @@ -105,9 +111,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Override
public void cancel(OrderRequest orderRequest){
logger.info("Buyer Order cancel (OrderRequest) {}", orderRequest);
OrderStatus expectStatus = OrderStatus.WAITING_PAY;
OrderStatus targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_PAY;
cancelBeforePaid(orderRequest, expectStatus, targetStatus);
doCancel(orderRequest);
}
@Override
... ... @@ -115,14 +119,59 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
logger.info("Buyer Order cancel time out ,(OrderRequest) {}", orderRequest);
OrderStatus expectStatus = OrderStatus.WAITING_PAY;
OrderStatus targetStatus = OrderStatus.BUYER_CANCEL_TIMEOUT;
cancelBeforePaid(orderRequest, expectStatus, targetStatus);
DataNode node = checkBase(orderRequest);
cancelBeforePaid(orderRequest, node, expectStatus, targetStatus);
}
private void doCancel(OrderRequest orderRequest){
DataNode node = checkBase(orderRequest);
BuyerOrder buyerOrder = node.buyerOrderInDB;
Integer orderStatus = buyerOrder.getStatus();
OrderStatus expectStatus = null ;
if (orderStatus == null || (expectStatus = OrderStatus.getOrderStatus(orderStatus))== null){
logger.warn("in buyer cancel check orderStatus fail, orderStatus {} expectStatus {}", orderStatus,expectStatus );
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
logger.info("in buyer cancel, req {} expectStatus {}", orderRequest, expectStatus);
//case 1 :支付前
//case 2 :支付后,卖家发货前
//case 3 :卖家发货后,鉴定中心接受前
OrderStatus targetStatus;
switch (expectStatus){
case WAITING_PAY:
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_PAY;
cancelBeforePaid(orderRequest, node, expectStatus, targetStatus);
break;
case HAS_PAYED:
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(orderRequest.getUid(),
orderRequest.getOrderCode());
int skup = bog.getSkup();
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER;
BeforeSellerDeliverEvent bsde = BeforeSellerDeliverEvent.builder()
.buyerUid(orderRequest.getUid()).orderCode(orderRequest.getOrderCode())
.expected(expectStatus).target(targetStatus).skup(skup).sellerUid(buyerOrder.getSellerUid())
.build();
buyerOrderCancelService.cancel(bsde);
break;
case SELLER_SEND_OUT:
bog = buyerOrderGoodsMapper.selectByOrderCode(orderRequest.getUid(),
orderRequest.getOrderCode());
skup = bog.getSkup();
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
BeforeDepotReceiveEvent bdre = BeforeDepotReceiveEvent.builder()
.buyerUid(orderRequest.getUid()).orderCode(orderRequest.getOrderCode())
.expected(expectStatus).target(targetStatus).skup(skup).sellerUid(buyerOrder.getSellerUid())
.build();
buyerOrderCancelService.cancel(bdre);
break;
}
}
public void cancelBeforePaid(OrderRequest orderRequest, OrderStatus exceptStatus, OrderStatus targetStatus){
public void cancelBeforePaid(OrderRequest orderRequest, DataNode dataNode, OrderStatus exceptStatus, OrderStatus targetStatus){
// 状态 ![待付款] 不合法
DataNode dataNode = checkStatusAndRequest(orderRequest, exceptStatus);
checkStatus(dataNode, orderRequest, exceptStatus);
// 更新订单状态
final OrderStatus orderStatus = targetStatus;
... ... @@ -166,12 +215,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
private class DataNode{
BuyerOrder buyerOrderInDB;
}
/**
*
* @param orderRequest
* @param orderStatusEx
*/
private DataNode checkStatusAndRequest(OrderRequest orderRequest, OrderStatus orderStatusEx ) {
private DataNode checkBase(OrderRequest orderRequest){
// 参数检查
if (orderRequest.getUid() < 0
|| orderRequest.getOrderCode() < 0){
... ... @@ -187,7 +232,19 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
orderRequest.getUid(), orderRequest.getOrderCode() );
throw new ServiceException(ServiceError.ORDER_NULL);
}
DataNode node = new DataNode();
node.buyerOrderInDB = buyerOrder;
return node;
}
/**
*
* @param orderRequest
* @param orderStatusEx
*/
private void checkStatus(DataNode node, OrderRequest orderRequest, OrderStatus orderStatusEx ) {
BuyerOrder buyerOrder = node.buyerOrderInDB;
// 检查 订单状态
int status = buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus().intValue();
OrderStatus orderStatus = OrderStatus.getOrderStatus(status);
... ... @@ -196,9 +253,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrder.getStatus());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
DataNode node = new DataNode();
node.buyerOrderInDB = buyerOrder;
return node;
}
... ...
package com.yohoufo.order.service.impl;
import com.yohoufo.common.utils.BigDecimalHelper;
import lombok.Data;
import lombok.Getter;
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.math.BigDecimal;
/**
* Created by chao.chen on 2018/11/15.
*/
@Component("orderDynamicConfig")
public class OrderDynamicConfig {
final private Logger logger = LoggerFactory.getLogger(getClass());
@Data
public static class BuyerCancelCompensateNode{
/**
* 卖家赔偿金额
*/
private BigDecimal buyerCompensateMoney;
/**
* 卖家获取的赔偿金额
*/
private BigDecimal sellerGetMoney;
/**
* 赔偿比例
*/
private BigDecimal compensateRate;
public BuyerCancelCompensateNode(BigDecimal buyerCompensateMoney, BigDecimal compensateRate) {
this.buyerCompensateMoney = buyerCompensateMoney;
this.compensateRate = compensateRate;
this.sellerGetMoney = BigDecimalHelper.halfUp(buyerCompensateMoney.multiply(compensateRate));
}
}
/**
* 卖家发货前
*/
@Value("${order.buyer.cancelWhenSellerUnDelivery.money}")
private String buyerCancelUnDelivery;
@Value("${order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate}")
private String sellerGetRateUnDelivery;
/**
* 卖家发货后 鉴定中心收货前
*/
@Value("${order.buyer.cancelWhenSellerDelivery.money}")
private String buyerCancelDelivery;
@Value("${order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate}")
private String sellerGetRateDelivery;
/**
* 卖家发货,买家赔偿金额 比例 ,卖家获取金额
*/
@Getter
private BuyerCancelCompensateNode beforeSellerDeliverBCCN;
/**
* 卖家未发货,买家赔偿金额
*/
@Getter
private BuyerCancelCompensateNode beforeDepotReceiveBCCN;
@PostConstruct
private void init() {
BigDecimal buyerCancelUnDeliveryMoney , beforeSellerDeliverRate;
BigDecimal buyerCancelDeliveryMoney, beforeDepotReceiveRate;
try {
buyerCancelDeliveryMoney = new BigDecimal(buyerCancelUnDelivery);
beforeSellerDeliverRate = new BigDecimal( sellerGetRateUnDelivery);
//包装结构时做格式化,之前请保留有效位
beforeSellerDeliverBCCN = new BuyerCancelCompensateNode(BigDecimalHelper.halfUp(buyerCancelDeliveryMoney),
BigDecimalHelper.halfUp(beforeSellerDeliverRate) );
buyerCancelUnDeliveryMoney = new BigDecimal(buyerCancelDelivery);
beforeDepotReceiveRate = new BigDecimal(sellerGetRateDelivery);
beforeDepotReceiveBCCN = new BuyerCancelCompensateNode(buyerCancelUnDeliveryMoney, beforeDepotReceiveRate);
} catch (Exception e) {
logger.error("买家取消罚款金额相关参数配置错误!", e);
throw new Error("买家取消罚款金额相关参数配置错误!");
}
if (buyerCancelDeliveryMoney.compareTo(BigDecimal.ZERO) < 0) {
throw new Error("buyerCancelDeliveryMoney买家取消(货已寄出)罚款金额不能为负数");
}
if (buyerCancelUnDeliveryMoney.compareTo(BigDecimal.ZERO) < 0) {
throw new Error("buyerCancelUnDeliveryMoney买家取消(货未寄出)罚款金额不能为负数");
}
if (beforeDepotReceiveRate.compareTo(BigDecimal.ZERO) < 0
|| beforeDepotReceiveRate.compareTo(BigDecimal.ONE) > 0) {
throw new Error("sellerGetRateDeliveryMoney买家取消(货已寄出)卖家获得赔偿比率必须在[0,1]");
}
if (beforeSellerDeliverRate.compareTo(BigDecimal.ZERO) < 0
|| beforeSellerDeliverRate.compareTo(BigDecimal.ONE) > 0) {
throw new Error("sellerGetRateUnDeliveryMoney买家取消(货未寄出)卖家获得赔偿比率必须在[0,1]");
}
}
}
... ...
... ... @@ -17,6 +17,7 @@ import com.yohoufo.common.utils.TimeUtils;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.common.TransferCase;
import com.yohoufo.order.constants.RefundContant;
import com.yohoufo.order.model.PayQueryBo;
import com.yohoufo.order.model.PayRefundBo;
... ... @@ -29,6 +30,7 @@ import com.yohoufo.order.service.AbstractOrderPaymentService;
import com.yohoufo.order.service.BuyerOrderPaymentService;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.SellerOrderPaymentService;
import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
import com.yohoufo.order.service.pay.AbstractPayService;
import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
import com.yohoufo.order.service.pay.weixin.WeixinMiniappPayService;
... ... @@ -41,15 +43,29 @@ import org.apache.commons.lang3.StringUtils;
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.Date;
import javax.annotation.PostConstruct;
@Service
public class PaymentServiceImpl implements IPaymentService {
public enum TargetUserType {
buyer(1),seller(2);
int code;
TargetUserType(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}
private static final Logger logger = LoggerUtils.getPayConfirmLogger();
... ... @@ -101,7 +117,11 @@ public class PaymentServiceImpl implements IPaymentService {
@Autowired
TradeBillsMapper tradeBillsMapper;
@Autowired
private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler;
/**
* 获取主场的订单service
* @param codeMeta
... ... @@ -123,6 +143,9 @@ public class PaymentServiceImpl implements IPaymentService {
}else if(codeMeta.getType() == OrderCodeType.SELLER_TYPE.getType()){
paymentService = this.sellerOrderPaymentService;
}else if(codeMeta.getType() == OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType()){
// TODO
paymentService = this.sellerOrderPaymentService;
}
return paymentService;
... ... @@ -402,11 +425,15 @@ public class PaymentServiceImpl implements IPaymentService {
}
/**
* <pre>
* 1:鉴定通过(货款-->卖家);
* 2:鉴定不通过(保证金 --> 买家);
* 3:有买家时卖家不卖了(保证金 --> 买家)
* // 20181109 add
* 4:买家付款后[卖家未发货],取消订单(货款部分-->卖家);
* 5:买家付款后[卖家已发货],取消订单(货款部分-->卖家);
* </pre>
*
* @param request 请求
... ... @@ -414,18 +441,17 @@ public class PaymentServiceImpl implements IPaymentService {
@Database(ForceMaster = true)
public void transferMon(TransferMoneyRequest request){
logger.info("transferMon转账开始,request = {}", request);
long buyerOrderCode = request.getBuyerOrderCode();
int transferType = request.getType();
logger.info("transferMon参数检查");
// 订单号check
if (buyerOrderCode < 1) {
if (buyerOrderCode < 1L) {
logger.warn("transferMonErr orderCode empty");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
// 类型检查
if (transferType < 1 || transferType > 3) {
int transferType = request.getType();
TransferCase transferCase = TransferCase.getTransferCase(transferType);
if (transferCase == null) {
logger.warn("transferMonErr transferType invalid");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
... ... @@ -451,7 +477,10 @@ public class PaymentServiceImpl implements IPaymentService {
}
long sellerOrderCode = sellerOrder.getOrderCode();
Integer targetUid = transferType == 1 ? sellerOrder.getUid() : buyerOrder.getUid();
TargetUserType targetUserType = (transferType == TransferCase.APPRAISE_FAIL.getCode()
|| transferType == TransferCase.SELLER_PLAY_BUYER.getCode()) ? TargetUserType.buyer : TargetUserType.seller;
//Integer targetUserType = (transferType == 2 || transferType == 3) ? 1 : 2;
Integer targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerOrder.getUid();
if (targetUid == null || targetUid < 1) {
logger.warn("transferMonErr uid {} 不合法", targetUid);
... ... @@ -488,11 +517,11 @@ public class PaymentServiceImpl implements IPaymentService {
TradeBills record = new TradeBills();
record.setUid(targetUid);
record.setOrderCode(buyerOrderCode);
record.setUserType(transferType == 1 ? 2 : 1);
record.setUserType(targetUserType.getCode());
record.setPayType(1);
record.setTradeType(transferType == 1 ? 2 : 3);
record.setIncomeOutcome(1);
record.setTradeStatus(transferType == 1 ? 0 : 1);
record.setTradeStatus(0);
record.setCreateTime(now);
logger.info("transferMon参数检查成功!");
... ... @@ -500,7 +529,7 @@ public class PaymentServiceImpl implements IPaymentService {
logger.info("transferMon插入初始化转账信息成功,接下来计算费用");
// 算费
BigDecimal transferAmount = calcTransferAmount(sellerOrder.getUid(), sellerOrder.getSkup(), transferType);
BigDecimal transferAmount = calcTransferAmount(sellerOrder.getUid(), sellerOrder.getSkup(), transferCase);
logger.info("transferMon计算费用结果为 {}", transferAmount);
if (transferAmount == null) {
logger.warn("transferMonErr transferMon计算费用结果为 null, 不合法的金额");
... ... @@ -590,7 +619,7 @@ public class PaymentServiceImpl implements IPaymentService {
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
// 类型检查
if (transferType < 1 || transferType > 3) {
if (transferType < 1 || transferType > 5) {
logger.warn("transferMonErr transferType invalid");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
... ... @@ -897,9 +926,23 @@ public class PaymentServiceImpl implements IPaymentService {
addTradeBills(record);
}
private BigDecimal getBuyerCancelBeforeSellerDeliver(){
//todo
return buyerCancelCompensateComputeHandler.calBeforeSellerDeliver();
}
private BigDecimal getBuyerCancelBeforeDepotReceive(){
//todo
return buyerCancelCompensateComputeHandler.calBeforeDepotReceive();
}
private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup, int transferType) {
private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup, TransferCase transferCase) {
if (transferCase == TransferCase.BUYER_CANCEL_BEFORE_SELLER_DELIVER) {
return getBuyerCancelBeforeSellerDeliver();
}
if (transferCase == TransferCase.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE) {
return getBuyerCancelBeforeDepotReceive();
}
SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");
if (meta == null) {
logger.warn("查询SellerOrderMeta无数据, sellerUid is {}, skup is {}", sellerUid, skup);
... ... @@ -913,7 +956,7 @@ public class PaymentServiceImpl implements IPaymentService {
try {
JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
// 交易成功的情况
if (transferType == 1) {
if (transferCase == TransferCase.APPRAISE_SUCCESS) {
return metavalue.getBigDecimal("income");
}
// (1-Y)*A
... ... @@ -1023,10 +1066,4 @@ public class PaymentServiceImpl implements IPaymentService {
}
... ...
... ... @@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
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.common.*;
import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail;
import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo;
import com.yohoufo.common.constant.ExpressInfoConstant;
... ... @@ -26,6 +23,7 @@ import com.yohoufo.order.model.response.GoodsInfo;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohoufo.order.service.IOrderDetailService;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
... ... @@ -73,6 +71,9 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
@Autowired
private OrderCacheService orderCacheService;
@Autowired
private UserProxyService userProxyService;
private static List<SkupStatus> noNeedShowOrderCode = Arrays.asList(SkupStatus.CAN_NOT_SELL,SkupStatus.CAN_SELL,
SkupStatus.SELF_CANCEL_PAY, SkupStatus.TIMEOUT_CANCEL,
SkupStatus.SELLER_CANCEL_SELL, SkupStatus.YOHO_CANCEL_SELL);
... ... @@ -103,12 +104,14 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
logger.warn("can not find seller order, req {}", orderRequest);
return null;
}
boolean isEntry = userProxyService.isEntryShop(uid);
SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
Integer skup = sellerOrder.getSkup();
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
Integer skupStatusCode = sellerOrderGoods.getStatus();
SkupStatus skupStatus = SkupStatus.getSkupStatus(skupStatusCode);
AddressInfo addressInfo = sellerAddressService.getHiddenAddressInfo(uid, skup);
orderDetailInfo = buildOrderDetail(sellerOrder, skupStatus, sellerOrderGoods, addressInfo);
orderDetailInfo = buildOrderDetail(sellerOrder, skupStatus, sellerOrderGoods, addressInfo, sellerType);
}else{
orderDetailInfo = super.getOrderDetail(orderRequest);
}
... ... @@ -273,12 +276,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
}
private OrderDetailInfo buildOrderDetail(SellerOrder order, SkupStatus skupStatus,
SellerOrderGoods sellerOrderGoods, AddressInfo addressInfo
SellerOrderGoods sellerOrderGoods, AddressInfo addressInfo,
SellerType sellerType
) {
OrderDetailInfo orderDetailInfo = new OrderDetailInfo();
orderDetailInfo.setUid(order.getUid());
orderDetailInfo.setOrderCode(getOrderCode(skupStatus, order));
orderDetailInfo.setButtons(skupStatus.getDetailButtons());
orderDetailInfo.setButtons(skupStatus.getDetailButtons(sellerType));
orderDetailInfo.setSubmitOrderTimeStr(DateUtil.formatDate(order.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
orderDetailInfo.setUserAddress(addressInfo);
//卖家
... ...
... ... @@ -5,6 +5,7 @@ import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.common.SellerOrderListType;
import com.yohobuy.ufo.model.order.common.SellerOrderStatus;
import com.yohobuy.ufo.model.order.common.SellerType;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
... ... @@ -22,6 +23,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.IOrderListService;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.proxy.UserProxyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -54,6 +56,9 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
@Autowired
private OrderCacheService orderCacheService;
@Autowired
private UserProxyService userProxyService;
@Override
public PageResp<OrderListInfo> getOrderList(OrderListRequest request){
... ... @@ -73,7 +78,8 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
int type;
if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()){
List<Integer> statusList = initOrderListRequest(request);
boolean isEntry = userProxyService.isEntryShop(request.getUid());
final SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
int total = sellerOrderGoodsMapper.selectCntByUidStatusList(request.getUid(), statusList);
int limit = request.getLimit();
respBuilder = PageResp.builder()
... ... @@ -98,7 +104,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
List<SellerOrder> sellerOrders = sellerOrderMapper.selectBySkups(skupList);
List<OrderListInfo> data ;
data = sellerOrders.parallelStream()
.map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()), sellerOrder))
.map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()), sellerOrder, sellerType))
.filter(oli -> Objects.nonNull(oli))
.collect(Collectors.toList());
... ... @@ -132,7 +138,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
}
OrderListInfo buildOrderListInfo(SellerOrderGoods sellerOrderGoods,
SellerOrder sellerOrder) {
SellerOrder sellerOrder, SellerType sellerType) {
OrderListInfo orderListInfo = new OrderListInfo();
orderListInfo.setUid(sellerOrder.getUid());
... ... @@ -152,7 +158,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
orderListInfo.setStatuStr(skupStatus.getDesc());
// 按钮显示
orderListInfo.setButtons(skupStatus.getListButtons());
orderListInfo.setButtons(skupStatus.getListButtons(sellerType));
// 当订单状态是待付款, 显示leftTime
if (sellerOrderGoods.getStatus() == SkupStatus.CAN_NOT_SELL.getCode()){
... ...
... ... @@ -2,33 +2,35 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.req.SellerOrderCancelReq;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohobuy.ufo.model.order.req.*;
import com.yohobuy.ufo.model.order.resp.BatchChangePriceResp;
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.utils.AddressUtil;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.*;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.event.ErpCancelSellerOrderEvent;
import com.yohoufo.order.event.EventHandlerContainer;
import com.yohoufo.order.event.OrderCancelEvent;
import com.yohoufo.order.model.AddressInfo;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.model.response.OrderSummaryResp;
import com.yohoufo.order.service.IOrderDetailService;
... ... @@ -37,16 +39,12 @@ import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
import com.yohoufo.order.service.handler.SellerOrderSubmitHandler;
import com.yohoufo.order.service.impl.processor.SellerOrderPrepareProcessor;
import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase;
import com.yohoufo.order.service.impl.visitor.UserCancelCase;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import com.yohoufo.order.utils.AddressHelper;
import com.yohoufo.product.model.GoodsSize;
import com.yohoufo.product.model.ProductInfo;
import com.yohoufo.product.response.StorageDataResp;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -65,7 +63,6 @@ import java.util.stream.Collectors;
@Slf4j
public class SellerOrderService implements IOrderListService, IOrderDetailService {
@Autowired
private SellerOrderMapper sellerOrderMapper;
... ... @@ -82,9 +79,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
private SellerOrderSubmitHandler orderSubmitHandler;
@Autowired
private UserProxyService userProxyService;
@Autowired
private SellerOrderListService sellerOrderListService;
@Autowired
... ... @@ -108,16 +102,27 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
@Autowired
private CacheCleaner cacheCleaner;
@Autowired
private SellerOrderPrepareProcessor sellerOrderPrepareProcessor;
public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException {
log.info("in computePublishPrd, req {}", req);
int uid = req.getUid();
if(uid <= 0){
log.warn("in computePublishPrd uid illegal , req {}", req);
throw new GatewayException(400, "用户ID错误");
}
//
Integer storageId = req.getStorageId();
if (storageId <=0 ){
log.warn("in computePublishPrd storageId illegal , req {}", req);
throw new GatewayException(400, "storageId 错误");
}
int num;
if ((num = req.getNum())<=0){
log.warn("in computePublishPrd num illegal , req {}", req);
throw new GatewayException(400, "非法数量值");
}
/*商品鉴定费 ¥10.00
商品包装费 ¥10.00
... ... @@ -134,42 +139,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
throw new GatewayException(400, "价格须为以9结尾的正整数");
}
BigDecimal prdPrice = null;
try{
prdPrice = new BigDecimal(price);
}catch (Exception e){
log.warn("in computePublishPrd price convert BigDecimal fail, {}", req);
return null;
}
checkPrice(storageId, prdPrice, false);
return buildSoldPrdComputeBo(prdPrice);
}
void checkPrice(int storageId, BigDecimal prdPrice, boolean validateMaxPrice) throws GatewayException {
ProductInfo productInfo = productProxyService.getPrdPriceRange(storageId);
BigDecimal minPrice = productInfo.getMinPrice();
BigDecimal maxPrice = productInfo.getMaxPrice();
if (prdPrice.subtract(minPrice).doubleValue() < 0D){
log.warn("in computePublishPrd,minPrice {}, storageId {}", minPrice, storageId);
throw new GatewayException(501, "您的出价过低");
}
if (validateMaxPrice && prdPrice.subtract(maxPrice).doubleValue() > 0D){
log.warn("in computePublishPrd,maxPrice {}, storageId {}", maxPrice, storageId);
throw new GatewayException(501, "您的出价过高");
}
}
void checkIncome(int storageId, BigDecimal income) throws GatewayException {
if (income == null || income.compareTo(BigDecimal.ZERO) <= 0){
log.warn("in checkIncome,storageId {}, income {}", income);
throw new GatewayException(501, "别闹了,这个售价没有收入");
throw new GatewayException(400, "非法数字");
}
sellerOrderPrepareProcessor.checkPrice(storageId, prdPrice, false);
return buildSoldPrdComputeBo(uid, num, prdPrice);
}
/**
... ... @@ -180,22 +158,22 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
*/
public OrderSubmitResp publishPrd(SellerOrderSubmitReq req) throws GatewayException {
SellerOrderContext context = buildSellerOrderContext(req);
SellerOrderContext context = sellerOrderPrepareProcessor.buildSellerOrderContext(req);
int storageId = context.getStorageId();
int uid = context.getUid();
//step 1: rpc get product detail by storage id
//ufo.product.storage.data
GoodsInfo goodsInfo = getProductDetail(context);
GoodsInfo goodsInfo = sellerOrderPrepareProcessor.getProductDetail(context);
//step 2: generate skup ,action :set price status(unsaleable)
if (Objects.isNull(goodsInfo)){
log.warn("in computePublishPrd storageId not exist in prd , uid {}, storageId {}", uid, storageId);
log.warn("in publishPrd storageId not exist in prd service , uid {}, storageId {}", uid, storageId);
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
context.setSoldProduct(goodsInfo);
checkPrice(storageId, goodsInfo.getPrice(), true);
sellerOrderPrepareProcessor.checkPrice(storageId, goodsInfo.getPrice(), true);
// compute every fee from price
SellerOrderComputeResult computeResult = computeHandler.compute(goodsInfo.getPrice());
checkIncome(storageId, computeResult.getIncome());
sellerOrderPrepareProcessor.checkIncome(storageId, computeResult.getIncome());
log.info("in publishPrd , uid {}, storageId {}, price {}, computeResult {}", uid, storageId,
goodsInfo.getPrice(), computeResult);
context.setSellerOrderComputeResult(computeResult);
... ... @@ -241,98 +219,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}
private GoodsInfo getProductDetail(SellerOrderContext context){
int uid = context.getUid();
int storageId = context.getStorageId();
BigDecimal salePrice = context.getSalePrice();
try {
StorageDataResp prdResp = productProxyService.getStorageData(storageId);
if (!Integer.valueOf(1).equals(prdResp.getStatus())) {
log.info("in getProductDetail occur product out shelve, uid {}, storageId {}", uid, storageId);
return null;
}
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.setUid(uid);
goodsInfo.setProductId(prdResp.getProductId());
goodsInfo.setProductName(prdResp.getProductName());
goodsInfo.setColorId(Objects.isNull(prdResp.getColorId()) ? null : Integer.valueOf(prdResp.getColorId()));
goodsInfo.setColorName(prdResp.getColorName());
GoodsSize size;
if (Objects.nonNull(size =prdResp.getSize())){
goodsInfo.setSizeName(size.getSizeName());
goodsInfo.setSizeId(size.getSizeId());
}
goodsInfo.setImageUrl(prdResp.getImageUrl());
goodsInfo.setPrice(salePrice);
goodsInfo.setStorageId(context.getStorageId());
return goodsInfo;
}catch (Exception ex){
log.warn("in getProductDetail occur error, uid {}, storageId {}", uid, storageId);
return null;
}
}
private SellerOrderContext buildSellerOrderContext(SellerOrderSubmitReq req) throws GatewayException {
int uid = req.getUid();
if (uid <= 0){
log.warn("uid illegal , uid {}", uid);
throw new GatewayException(400, "Uid 错误");
}
Integer storageId = req.getStorageId();
if (storageId <=0 ){
log.warn("storageId illegal , uid {}", uid);
throw new GatewayException(400, "storageId 错误");
}
String price = req.getPrice();
if (StringUtils.isBlank(price)){
log.warn("in buildSellerOrderContext price illegal , req {}", req);
throw new GatewayException(400, "没有价格");
}
if(!price.endsWith("9")){
log.warn("in buildSellerOrderContext price illegal , req {}", req);
throw new GatewayException(400, "价格须为以9结尾的正整数");
}
BigDecimal salePrice;
try{
salePrice = new BigDecimal(req.getPrice());
}catch (Exception ex){
log.warn("storageId illegal , uid {}", uid);
throw new GatewayException(400, "售价格式错误");
}
int addressId = AddressUtil.getDecryptStr(req.getAddressId());
if (addressId < 0){
log.warn("seller submit order addressId invalidate, uid {}, storageId {}, addressId is {}",
uid, storageId, req.getAddressId());
throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);
}
//the address of send back 2 seller
//
AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId);
AddressInfo noHiddenBackAddress = userProxyService.getAddressInfoNotHidden(uid, addressId);
if(AddressHelper.isNeedUpdate(noHiddenBackAddress)){
log.warn("seller submit addressId need update, uid is {}, storageId is {}, addressId is {}",
uid, storageId, addressId);
throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);
}
//
SellerOrderContext context = new SellerOrderContext();
context.setUid(uid);
context.setStorageId(storageId);
context.setSalePrice(salePrice);
//
context.setBackAddress(noHiddenBackAddress);
context.setBackHiddenAddress(hiddenBackAddress);
return context;
}
/**
* 卖家支付完成后调用
* @param uid
... ... @@ -354,6 +240,21 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}
@Autowired
private SkupBatchService skupBatchService;
public void batchPublishPrds(SellerOrderSubmitReq req) throws GatewayException {
// 一串校验
SellerOrderContext ctx = sellerOrderPrepareProcessor.buildBatchSellerOrderContext(req);
//TODO 扣减保证金
//TODO (异步实现)记录保证金流水
//TODO 生成批次号
skupBatchService.generateBatchNo(req.getUid(), req.getNum());
//TODO 批量生成订单(订单表,meta 地址,算费)--> 需要用到多线程并行处理
//TODO(异步实现)同步数据到prd,记录支付,
}
public boolean offShelveByErp(int skup){
if (skup <= 0 ){
... ... @@ -366,6 +267,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
return true;
}
public boolean batchCancel(SellerOrderBatchCancelReq req){
return true;
}
public boolean cancel(SellerOrderCancelReq req){
log.info("seller self cancel order,req {}", req);
... ... @@ -435,16 +341,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
if(OrderCodeType.BUYER_TYPE.getType() == codeMeta.getType()){
BuyerOrder buyerOrder = buyerOrderMapper.selectAllByOrderCode(orderCode);
//todo 判断状态后更新
//判断状态后更新
checkBuyCanDelStatus(buyerOrder.getStatus());
BuyerOrder target = new BuyerOrder();
target.setId(buyerOrder.getId());
target.setSellerOrderStatus(DelStatus.IS_DEL.getCode());
target.setUpdateTime(DateUtil.getCurrentTimeSecond());
buyerOrderMapper.updateByPrimaryKeySelective(target);
}
cacheCleaner.cleanList(uid, TabType.SELL.getValue());
return true;
}
... ... @@ -476,10 +380,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}
public SoldPrdComputeBo buildSoldPrdComputeBo(BigDecimal prdPrice){
private SoldPrdComputeBo buildSoldPrdComputeBo(int uid, int num, BigDecimal prdPrice){
SellerOrderComputeResult computeResult = computeHandler.compute(prdPrice);
/**
* 验证是否是入驻商家
*/
sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, computeResult, num, prdPrice);
SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
return computeBo;
}
... ... @@ -497,8 +403,6 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
return sellerOrderDetailService.getOrderDetail(orderRequest);
}
/**
* 根据用户id查询卖的单数
* 出售栏目显示的数量=出售tab下商品“出售中”状态的数量+待发货tab下所有的订单数+已发货tab下所有订单数
... ... @@ -547,4 +451,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
.actor(orderRequest.getTabType()).build();
}
public BatchChangePriceResp batchChangePrice(BatchChangePriceReq req){
BatchChangePriceResp resp = BatchChangePriceResp.builder().successCnt(1).failCnt(1)
.tips("变价成功1个,失败1个").build();
return resp;
}
}
... ...
package com.yohoufo.order.service.impl;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.SkupBatchMapper;
import com.yohoufo.dal.order.model.SkupBatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
/**
* Created by chao.chen on 2018/11/19.
*/
@Service
public class SkupBatchService {
private final Logger logger = LoggerFactory.getLogger(getClass());
private SkupBatchMapper skupBatchMapper;
public Long generateBatchNo(int uid, int num){
SkupBatch record = new SkupBatch();
record.setUid(uid);
record.setNum(num);
record.setCreateTime(DateUtil.getCurrentTimeSecond());
skupBatchMapper.insertSelective(record);
return record.getId();
}
}
... ...
package com.yohoufo.order.service.impl;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.SkupBatchMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
... ... @@ -24,6 +26,9 @@ public class SkupService {
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
private SkupBatchMapper skupBatchMapper;
@Transactional(propagation = Propagation.REQUIRED)
@Database(ForceMaster=true, DataSource="ufo_order")
public SellerOrderGoods addSkup(GoodsInfo goodsInfo){
... ... @@ -58,6 +63,10 @@ public class SkupService {
return sellerOrderGoods;
}
public void batchPublishPrds(SellerOrderSubmitReq req){
}
}
... ...
package com.yohoufo.order.service.impl.processor;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.common.SellerWalletType;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.utils.AddressUtil;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.dal.order.SellerWalletMapper;
import com.yohoufo.dal.order.model.SellerWallet;
import com.yohoufo.order.model.AddressInfo;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.utils.AddressHelper;
import com.yohoufo.product.model.GoodsSize;
import com.yohoufo.product.model.ProductInfo;
import com.yohoufo.product.response.StorageDataResp;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Objects;
/**
* Created by chao.chen on 2018/11/19.
*/
@Service
public class SellerOrderPrepareProcessor {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
private UserProxyService userProxyService;
@Autowired
private ProductProxyService productProxyService;
@Autowired
private SellerOrderComputeHandler computeHandler;
@Autowired
private SellerWalletMapper sellerWalletMapper;
public SellerOrderContext buildBatchSellerOrderContext(SellerOrderSubmitReq req) throws GatewayException {
SellerOrderContext ctx = buildSellerOrderContext(req);
int storageId = ctx.getStorageId();
int uid = ctx.getUid();
int storageNum = req.getNum();
if (storageNum <=0){
log.warn("in buildBatchSellerOrderContext storageNum illegal , uid {}, storageId {} storageNum {}",
uid, storageId, storageNum);
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
//step 1: rpc get product detail by storage id
//ufo.product.storage.data
GoodsInfo goodsInfo = getProductDetail(ctx);
//step 2: generate skup ,action :set price status(unsaleable)
if (Objects.isNull(goodsInfo)){
log.warn("in buildBatchSellerOrderContext storageId not exist in prd , uid {}, storageId {}", uid, storageId);
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
goodsInfo.setStorageNum(storageNum);
ctx.setSoldProduct(goodsInfo);
checkPrice(storageId, goodsInfo.getPrice(), true);
// compute every fee from price
SellerOrderComputeResult computeResult = computeHandler.compute(goodsInfo.getPrice());
checkIncome(storageId, computeResult.getIncome());
checkNGetMergeEarnestMoney(uid, computeResult, storageNum, goodsInfo.getPrice());
return ctx;
}
public SellerOrderContext buildSellerOrderContext(SellerOrderSubmitReq req) throws GatewayException {
int uid = req.getUid();
if (uid <= 0){
log.warn("uid illegal , uid {}", uid);
throw new GatewayException(400, "Uid 错误");
}
Integer storageId = req.getStorageId();
if (storageId <=0 ){
log.warn("storageId illegal , uid {}", uid);
throw new GatewayException(400, "storageId 错误");
}
String price = req.getPrice();
if (StringUtils.isBlank(price)){
log.warn("in buildSellerOrderContext price illegal , req {}", req);
throw new GatewayException(400, "没有价格");
}
if(!price.endsWith("9")){
log.warn("in buildSellerOrderContext price illegal , req {}", req);
throw new GatewayException(400, "价格须为以9结尾的正整数");
}
BigDecimal salePrice;
try{
salePrice = new BigDecimal(req.getPrice());
}catch (Exception ex){
log.warn("storageId illegal , uid {}", uid);
throw new GatewayException(400, "售价格式错误");
}
int addressId = AddressUtil.getDecryptStr(req.getAddressId());
if (addressId < 0){
log.warn("seller submit order addressId invalidate, uid {}, storageId {}, addressId is {}",
uid, storageId, req.getAddressId());
throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);
}
//the address of send back 2 seller
//
AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId);
AddressInfo noHiddenBackAddress = userProxyService.getAddressInfoNotHidden(uid, addressId);
if(AddressHelper.isNeedUpdate(noHiddenBackAddress)){
log.warn("seller submit addressId need update, uid is {}, storageId is {}, addressId is {}",
uid, storageId, addressId);
throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);
}
//
SellerOrderContext context = new SellerOrderContext();
context.setUid(uid);
context.setStorageId(storageId);
context.setSalePrice(salePrice);
//
context.setBackAddress(noHiddenBackAddress);
context.setBackHiddenAddress(hiddenBackAddress);
return context;
}
public GoodsInfo getProductDetail(SellerOrderContext context){
int uid = context.getUid();
int storageId = context.getStorageId();
BigDecimal salePrice = context.getSalePrice();
try {
StorageDataResp prdResp = productProxyService.getStorageData(storageId);
if (!Integer.valueOf(1).equals(prdResp.getStatus())) {
log.info("in getProductDetail occur product out shelve, uid {}, storageId {}", uid, storageId);
return null;
}
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.setUid(uid);
goodsInfo.setProductId(prdResp.getProductId());
goodsInfo.setProductName(prdResp.getProductName());
goodsInfo.setColorId(Objects.isNull(prdResp.getColorId()) ? null : Integer.valueOf(prdResp.getColorId()));
goodsInfo.setColorName(prdResp.getColorName());
GoodsSize size;
if (Objects.nonNull(size = prdResp.getSize())){
goodsInfo.setSizeName(size.getSizeName());
goodsInfo.setSizeId(size.getSizeId());
}
goodsInfo.setImageUrl(prdResp.getImageUrl());
goodsInfo.setPrice(salePrice);
goodsInfo.setStorageId(context.getStorageId());
return goodsInfo;
}catch (Exception ex){
log.warn("in getProductDetail occur error, uid {}, storageId {}", uid, storageId);
return null;
}
}
public void checkPrice(int storageId, BigDecimal prdPrice, boolean validateMaxPrice) throws GatewayException {
ProductInfo productInfo = productProxyService.getPrdPriceRange(storageId);
BigDecimal minPrice = productInfo.getMinPrice();
BigDecimal maxPrice = productInfo.getMaxPrice();
if (prdPrice.subtract(minPrice).doubleValue() < 0D){
log.warn("in computePublishPrd,minPrice {}, storageId {}", minPrice, storageId);
throw new GatewayException(501, "您的出价过低");
}
if (validateMaxPrice && prdPrice.subtract(maxPrice).doubleValue() > 0D){
log.warn("in computePublishPrd,maxPrice {}, storageId {}", maxPrice, storageId);
throw new GatewayException(501, "您的出价过高");
}
}
public void checkIncome(int storageId, BigDecimal income) throws GatewayException {
if (income == null || income.compareTo(BigDecimal.ZERO) <= 0){
log.warn("in checkIncome,storageId {}, income {}", storageId, income);
throw new GatewayException(501, "别闹了,这个售价没有收入");
}
}
public BigDecimal checkNGetMergeEarnestMoney(int uid, SellerOrderComputeResult computeResult, int num, BigDecimal prdPrice){
boolean isEntryShop = userProxyService.isEntryShop(uid);
BigDecimal mEarestMoney = null;
if(isEntryShop){
BigDecimal singleEarestMoney = computeResult.getEarnestMoney().getEarnestMoney();
mEarestMoney = BigDecimalHelper.halfUp(new BigDecimal(num).multiply(singleEarestMoney));
boolean isEnough = isEnough(uid, mEarestMoney);
if (!isEnough){
log.warn("in buildSoldPrdComputeBo,wallet is not enough,uid {} num {} prdPrice {} singleEarestMoney {}",
uid, num, prdPrice, singleEarestMoney);
throw new ServiceException(ServiceError.WALLET_EARNESTMONEY_IS_NOT_ENOUGH);
}
}
return mEarestMoney;
}
/**
*
* @param uid
* @param mEarestMoney
* @return
*/
private boolean isEnough(int uid, BigDecimal mEarestMoney){
//取出入驻商家的钱包余额,判断保证金总额是否足够扣减
SellerWallet condition = new SellerWallet();
condition.setUid(uid);
condition.setType(SellerWalletType.EARNEAST_MONEY.getCode());
SellerWallet psw = sellerWalletMapper.selectByUidNType(condition);
log.info("in compare price, uid {}, mEarestMoney {}, SellerWallet {}", uid, mEarestMoney, psw);
if (psw !=null && psw.getAmount().compareTo(mEarestMoney) >= 0){
return true;
}
return false;
}
}
... ...
... ... @@ -14,6 +14,11 @@ public enum SmsContentEnum {
SMS_NOTIFIED_SEND_FAILED("您的商品{}未在规定时间内发货,平台已将您的保证金扣除并赔偿给买家。更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-出售]。"),
SMS_CLOSED_BUYER("买家已取消订单,您的商品{}已重新上架出售。更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-出售]。"),
SMS_NOTIFIED_UNSHELF("因为特殊原因,您的商品{}暂停售卖,您支付的保证金将于1个工作日内退回您的支付账户。"),
//给卖家发通知 ,当买家取消订单(付款后取消,卖家发货后取消,卖家商品已经被平台签收)
SMS_CANCELED_BY_BUYER_AFTER_PAID("买家已取消订单,您的商品「商品名称」已下架,更多信息请查看Yoho!Buy有货APP [UFO飞碟好物-我的-出售]。"),
SMS_CANCELED_BY_BUYER_AFTER_DELIVERY("买家已取消订单,请自行召回货品,如有其他疑问,请联系Yoho!Buy有货APP人工客服。"),
SMS_CANCELED_BY_BUYER_AFTER_RECEIVED("您的商品已顺丰到付退回,快递单号{},请注意查收。"),
;
private String content;
... ...
... ... @@ -8,6 +8,7 @@ import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.request.UserAddressReqBO;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.order.convert.AddressInfoConvertor;
import com.yohoufo.order.model.AddressInfo;
import org.apache.commons.lang3.StringUtils;
... ... @@ -38,6 +39,9 @@ public class UserProxyService {
@Value("${uic.url:http://uic.yohoops.org/uic}")
private String uicUrl;
@Autowired
private UfoServiceCaller ufoServiceCaller;
/**
* 获取用户信息
* @param uid
... ... @@ -133,4 +137,18 @@ public class UserProxyService {
}
return mobile;
}
public boolean isEntryShop(int uid){
//入驻商户 method=ufo.user.isStoredSeller ,入参 uid
ApiResponse userInfo ;
try {
userInfo = ufoServiceCaller.call("ufo.user.isStoredSeller", uid);
}catch (Exception ex){
logger.warn("in getMobile fail, uid {}", uid, ex);
throw new ServiceException(ServiceError.USER_IS_NOT_EXIST);
}
logger.info("judge user is entry shop, uid {} resp {}", uid, userInfo);
return (userInfo == null || userInfo.getData() == null) ? false : (boolean) userInfo.getData();
}
}
... ...
... ... @@ -4,12 +4,14 @@ package com.yohoufo.order.service.support.codegenerator.bean;
import lombok.Data;
/**
* <pre>
* 生成订单号bit元数据
* 订单号:
* 1位: 类型(标识是卖家订单号or买家订单号)
* 2位: 类型(标识是卖家订单号or买家订单号)
* 30位: 时间戳(秒级时间) 2的30次方/60/6024/365=34,也就是说可以用30年
* 10位: 序列号, 也就是说 每秒支持1K多的id
* 3位: 服务节点,支持8个服务节点
* </pre>
*/
@Data
public class CodeBitMeta {
... ... @@ -17,7 +19,7 @@ public class CodeBitMeta {
/**
* 类型
*/
private byte typeBits = 1;
private byte typeBits = 2;
/**
... ... @@ -35,7 +37,7 @@ public class CodeBitMeta {
*/
private byte machineBits = 3;
// 最右边长度为machineBits位为1,其他为0
public long getMachineBitsMask() {
return -1L ^ -1L << machineBits;
}
... ...
package com.yohoufo.order.service.support.codegenerator.populater;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.common.utils.IpUtils;
import org.apache.commons.lang3.StringUtils;
import com.yohoufo.dal.order.MachineIdGenerateMapper;
import com.yohoufo.dal.order.model.MachineIdGenerate;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class PropMachineIdProvider implements MachineIdProvider {
protected final Logger log = LoggerFactory.getLogger(this.getClass());
private Map<String, Long> ipsMap = new HashMap<String, Long>();
@Autowired
MachineIdGenerateMapper machineIdGenerateMapper;
@Value("${ips.machine}")
private String machineIps;
/**
* 默认的机器Id
* @return
*/
private long machineId = 0l;
@Override
public long getMachineId() {
return machineId;
}
@PostConstruct
public void init(){
String ip = IpUtils.getHostIp();
MachineIdGenerate machineIdGenerate = machineIdGenerateMapper.selectByIp(IpUtils.getHostIp());
if (machineIdGenerate != null){
machineId = machineIdGenerate.getMachineId();
log.info("machineId is {}", machineId);
return;
}
log.info("ip:{}, machineIps is {}",ip, machineIps);
Long machineId = ipsMap.get(ip);
// 初次启动,插入该ip的一条记录
Integer usableMachineId = getUsableMachineId();
int row = insertMachineId(usableMachineId, ip);
if (machineId == null){
return 0l;
if (row > 0){
machineId = usableMachineId.intValue();
log.info("machineId is {}", machineId);
return;
}
return machineId.longValue();
// 插入失败,重复的machineId, ==> 重试一次
usableMachineId = getUsableMachineId();
row = insertMachineId(usableMachineId, ip);
if (row > 0){
machineId = usableMachineId.intValue();
log.info("machineId is {}", machineId);
return;
}
throw new IllegalStateException("insert into ufo_order.machine_id_generate fail");
}
private int insertMachineId(Integer usableMachineId, String ip) {
@PostConstruct
public void init(){
if (StringUtils.isEmpty(machineIps)) {
return;
MachineIdGenerate db = new MachineIdGenerate();
db.setIp(ip);
db.setMachineId(usableMachineId.intValue());
db.setCreateTime(DateUtil.getCurrentTimeSecond());
return machineIdGenerateMapper.insert(db);
}
private Integer getUsableMachineId() {
List<MachineIdGenerate> machines = machineIdGenerateMapper.selectByAll();
if (CollectionUtils.isEmpty(machines)){
return 0;
}
String[] ips = machineIps.split(",");
List<Integer> machineIds = machines.stream().map(MachineIdGenerate::getMachineId).collect(Collectors.toList());
Integer usableMachineId = null;
for (int i=0; i<7; i++){
if (!machineIds.contains(Integer.valueOf(i))){
usableMachineId = Integer.valueOf(i);
break;
}
}
for (int i=0; i < ips.length; i++){
ipsMap.put(ips[i], (long)i);
// 无可用的machineid,联系管理员删除db数据
if (usableMachineId == null){
throw new IllegalStateException("check ufo_order.machine_id_generate machine 0-7 full.");
}
return usableMachineId;
}
}
... ...
package com.yohoufo.order.service;
import com.yohoufo.common.utils.IpUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.locks.InterProcessMultiLock;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.zookeeper.CreateMode;
import sun.net.util.IPAddressUtil;
import java.util.Arrays;
import java.util.List;
public class TestZKLock {
public static void main(String[] args) throws Exception{
String connectionStr = "192.168.102.45";
String lock_path = "/ufo/code_lock";
String path = "/ufo/machine/id";
CuratorFramework client = CuratorFrameworkFactory.builder()
.connectString(connectionStr)
.retryPolicy(new ExponentialBackoffRetry(1000, 3))
.sessionTimeoutMs(5000)
.connectionTimeoutMs(1000).build();
client.start();
InterProcessMultiLock lock = new InterProcessMultiLock(client, Arrays.asList(lock_path));
for (int i =0 ;i < 30; i++){
new Thread(new Runnable() {
@Override
public void run() {
try{
lock.acquire();
// 指定节点下面的 子节点
List<String> ids = client.getChildren().forPath(path);
if (CollectionUtils.isEmpty(ids)){
// 生成第一个节点
client.create().withMode(CreateMode.EPHEMERAL).forPath(path +"/0");
}else{
// 方案①
// 看看临时节点中哪个有空缺,则采用,
// 就会出现新的问题,zk上临时节点是空缺的,但是服务采用了那个空缺的id,所以必须监听重连
// 重连的时候,必须重新创建节点,更新服务使用的id
// 只需要 监听该节点被删除的时候,需要重新创建新的临时节点,更新machineId
// 一遍在获取,一遍在更新临时节点,非原子性,如果获取到的是旧的值,则有可能导致code重复
// 初始化的时候,给自己的ip 建立一个节点 自增,持久
// 方案②
// 直接采用ip==>数字
// 临时节点的话,没有必要记录ip,反正重发就已经删除了,也不会有根据ip获取id的情况
// 持久节点的话,要考虑什么事情清理
client.create().withMode(CreateMode.EPHEMERAL).forPath(path + "/" + IpUtils.getHostIp());
}
}catch (Exception e){
}finally {
try{
lock.release();
}catch (Exception e){
}
}
}
}).start();
}
Thread.sleep(Integer.MAX_VALUE);
}
}
... ...
package com.yohoufo.order.service;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.BackgroundCallback;
import org.apache.curator.framework.api.CuratorEvent;
import org.apache.curator.framework.recipes.cache.*;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.zookeeper.CreateMode;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
public class ZkTest {
public static void main(String[] args) throws Exception{
String rootPath = "/ufo/machine";
String path = rootPath + "/id";
String zookeeperConnectionString = "192.168.102.45";
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
CuratorFramework client = CuratorFrameworkFactory.builder()
.connectString(zookeeperConnectionString)
.sessionTimeoutMs(500)
.connectionTimeoutMs(5000)
.retryPolicy(retryPolicy)
.build();
client.start();
// 失败重连 监听
client.getConnectionStateListenable().addListener(new ConnectionStateListener() {
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState) {
System.out.println("当前客户端的连接状态: " +newState);
}
});
// 子节点监听
// PathChildrenCache cache = new PathChildrenCache(client, rootPath, true);
// cache.start();
// cache.getListenable().addListener(new PathChildrenCacheListener() {
// @Override
// public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
// System.out.println("事情类型" + event.getType());
// if (event.getData() != null){
// System.out.println("节点数据"+ event.getData().getPath() + " = " + new String(event.getData().getData()));
// }
// }
// });
String str = client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path);
System.out.println(str);
// 异步回调事件
String str2 = client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).inBackground(new BackgroundCallback() {
@Override
public void processResult(CuratorFramework curatorFramework, CuratorEvent curatorEvent) throws Exception {
System.out.println(curatorEvent.getResultCode() + "; " + curatorEvent.getType());
}
}).forPath(path);
System.out.println(str2);
// 现在的sessionId 0x1650ce0cd5a2482
// str.replace(path, "").replaceFirst("^0*","")
// 临时顺序节点,取模,一直自增,❌必然会出现 某几台机器的ip的顺序节点对8取模,结果是一样的,那么订单就有问题。
// or 把本机ip/序号 持久节点 固定ip获取到的机器保持一样的
// ①
// session超时,重连的时候,临时节点会重新创建吗
// curator不需要像clientZK一样,监听器,连接成功后,才往下处理 ❓❓❓
// 回答: 断开网络,通过链接的监听器,发现确实会自动重连,重连后能接受到子节点删除的事件,但是临时节点不会自动重新创建
// ②
// 当网络闪断重连的时候,sessionid发生改变,也就是说之前的session被清理了,临时节点也被清理了,问,临时节点上的watcher会不会被清理,客户端还能收到通知结果吗
// 实验证明不会 0x1650ce0cd5a24aa
// ③
// 如何模拟 SESSION_EXPIRE 的状态
//
List<String> ids = client.getChildren().forPath(rootPath);
for (String id : ids){
System.out.println("子节点路径=" + id + "; 子节点的数据=" + new String(client.getData().forPath(rootPath + "/" + id)));
NodeCache cache2 = new NodeCache(client, rootPath + "/" + id);
cache2.getListenable().addListener(new NodeCacheListener() {
@Override
public void nodeChanged() throws Exception {
ChildData data = cache2.getCurrentData();
if (null != data) {
System.out.println("节点数据:" + new String(cache2.getCurrentData().getData()));
} else {
System.out.println( "节点被删除!");
}
}
});
cache2.start();
}
// 当前的 sessionid 0x1650ce0cd5a2494
Thread.sleep(Integer.MAX_VALUE);
}
}
... ...
... ... @@ -6,7 +6,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.4.7-SNAPSHOT</version>
<version>1.4.8-SNAPSHOT</version>
</parent>
<groupId>com.yohoufo.fore</groupId>
... ...
package com.yohoufo.product.controller;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -171,6 +174,24 @@ public class ProductController {
}
}
/**
* 批量创建skup
* @param skupBo
* @return
*/
@RequestMapping(params = "method=ufo.product.batchCreateSkup")
public ApiResponse batchCreateSkup(@RequestBody List<StoragePriceBo> skupBoList) {
LOG.info("in method=ufo.product.batchCreateSkup skupBoList = {}", skupBoList);
try {
productService.batchCreateSkup(skupBoList);
return new ApiResponse(200, "创建成功!", Boolean.TRUE);
} catch (Exception e) {
LOG.error("创建SKUP失败!", e);
int code = (e instanceof ServiceException) ? ((ServiceException) e).getCode() : 500;
return new ApiResponse(code, e.getMessage(), Boolean.FALSE);
}
}
// 卖家修改状态:*1:可售(支付保证金),2:取消支付保证金,3:超时未支付保证金,4:支付保证金后取消售卖
@RequestMapping(params = "method=ufo.product.sellerUpdateStatus")
public ApiResponse sellerUpdateStatus(@RequestBody StoragePriceBo skupBo) {
... ... @@ -189,6 +210,34 @@ public class ProductController {
}
}
// 商家修改状态:1:上架 2:下架
@RequestMapping(params = "method=ufo.product.sellerBatchUpdateStatus")
public ApiResponse sellerBatchUpdateStatus(@RequestParam(value = "skupList", required = true) List<Integer> skupList,
@RequestParam(value = "status", required = true) Integer status){
LOG.info("in method=ufo.product.sellerBatchUpdateStatus skupList is {}, status is {}", skupList, status);
int dbStatus = 1;//上架
if(1 != status.intValue() && 2 != status.intValue()) {
throw new ServiceException(400, "status值不对,只能传1或2!");
}
//下架
if(2 == status.intValue()) {
dbStatus = 104;
}
try {
productService.sellerBatchUpdateStatus(skupList, dbStatus);
//清缓存
LOG.info("sellerUpdateStatus success and async clearProductCache skupList = {}", skupList);
clearBatchProductCache(skupList);
return new ApiResponse(200, "更新成功!", Boolean.TRUE);
} catch (Exception e) {
LOG.error("sellerBatchUpdateStatus失败!", e);
int code = (e instanceof ServiceException) ? ((ServiceException) e).getCode() : 500;
return new ApiResponse(code, e.getMessage(), Boolean.FALSE);
}
}
// 设置鉴定中心
@RequestMapping(params = "method=ufo.product.setDepotNum")
public ApiResponse setDepotNum(
... ... @@ -257,4 +306,35 @@ public class ProductController {
}
});
}
private void clearBatchProductCache(List<Integer> skupList) {
executors.execute(() -> {
try {
LOG.info("in clearBatchProductCache skupList = {}", skupList);
List<StoragePrice> spList = productService.getStoragePriceBySkupList(skupList);
List<Integer> productIdList = spList.stream().map(StoragePrice::getProductId).collect(Collectors.toList());
List<Integer> storageIdList = spList.stream().map(StoragePrice::getStorageId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(productIdList)) {
for(Integer productId : productIdList) {
LOG.info("clearCache queryProductDetailById productId = {}, ", productId);
//商品详情
cacheAop.clearCache(
ProductController.class.getMethod("queryProductDetailById", new Class[] { Integer.class }),
new Object[] { productId });
}
}
if(CollectionUtils.isNotEmpty(storageIdList)) {
for(Integer storageId : storageIdList) {
// sku最低价
LOG.info("clearCache queryStorageLeastprice storageId = {}, ", storageId);
cacheAop.clearCache(
ProductController.class.getMethod("queryStorageLeastprice", new Class[] { Integer.class }),
new Object[] { storageId });
}
}
} catch (Exception e) {
LOG.error("删除商品缓存失败!", e);
}
});
}
}
\ No newline at end of file
... ...
package com.yohoufo.product.service;
import com.yoho.core.dal.datasource.annotation.Database;
import java.util.List;
import com.yohoufo.dal.product.model.StoragePrice;
import com.yohoufo.product.request.StoragePriceBo;
import com.yohoufo.product.response.*;
import org.springframework.transaction.annotation.Transactional;
import com.yohoufo.product.response.ProductDetailResp;
import com.yohoufo.product.response.ProductSeriesTemplateResp;
import com.yohoufo.product.response.ProductSimpleResp;
import com.yohoufo.product.response.ProductSortTemplateResp;
import com.yohoufo.product.response.StorageDataResp;
import com.yohoufo.product.response.StorageLeastPriceResp;
public interface ProductService {
... ... @@ -34,4 +39,15 @@ public interface ProductService {
// 查询商品的基本信息
ProductDetailResp queryProductBaseInfo(Integer productId);
void batchCreateSkup(List<StoragePriceBo> skupBoList);
/**
* 卖家上架或下架商品
* @param skupList
* @param status
*/
void sellerBatchUpdateStatus(List<Integer> skupList, int status);
List<StoragePrice> getStoragePriceBySkupList(List<Integer> skupList);
}
... ...
... ... @@ -6,20 +6,20 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.yoho.core.dal.datasource.annotation.Database;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import com.google.common.collect.Lists;
import com.yoho.core.common.helpers.ImagesHelper;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.common.utils.DateUtil;
... ... @@ -169,6 +169,11 @@ public class ProductServiceImpl implements ProductService{
public StoragePrice getStoragePriceBySkup(Integer skup) {
return storagePriceMapper.selectBySkup(skup);
}
@Override
public List<StoragePrice> getStoragePriceBySkupList(List<Integer> skupList) {
return storagePriceMapper.selectBySkupList(skupList);
}
@Override
public ProductSortTemplateResp querySortTemplateData(String productIds) {
... ... @@ -235,6 +240,22 @@ public class ProductServiceImpl implements ProductService{
}
@Override
public void batchCreateSkup(List<StoragePriceBo> skupBoList) {
if(CollectionUtils.isEmpty(skupBoList)) {
throw new ServiceException(400, "skupBoList为空!");
}
List<StoragePrice> spList = Lists.newArrayList();
//校验
for(int i=0; i<skupBoList.size(); i++) {
StoragePrice sp = exchangeCreateSkupBo(skupBoList.get(i));
spList.add(sp);
}
//批量插入数据库
storagePriceMapper.insertBatch(spList);
}
@Override
public void sellerUpdateStatus(StoragePriceBo skupBo) {
// 卖家修改状态:*1:可售(支付保证金),2:取消支付保证金,3:超时未支付保证金,4:支付保证金后取消售卖
if (skupBo == null) {
... ... @@ -280,6 +301,37 @@ public class ProductServiceImpl implements ProductService{
}
@Override
public void sellerBatchUpdateStatus(List<Integer> skupList, int status) {
LOGGER.info("sellerBatchUpdateStatus in, skupList is {}, status is {}", skupList, status);
// 卖家修改上下架状态:*1:可售(支付保证金),商家上架,104:商家下架
int updateNum = storagePriceMapper.batchUpdateStatus(skupList, status);
if(updateNum == 0) {
throw new ServiceException(400, "更新上架状态失败!");
}
//获取storageId
List<StoragePrice> storagePriceList = storagePriceMapper.selectBySkupList(skupList);
Map<Integer, List<StoragePrice>> storagePriceMap = storagePriceList.stream().collect(Collectors.groupingBy(StoragePrice::getStorageId));
List<Storage> storageReqList = Lists.newArrayList();
for(Entry<Integer, List<StoragePrice>> entry : storagePriceMap.entrySet()) {
Storage storage = new Storage();
storage.setId(entry.getKey());
if(status == 1) {
storage.setStorageNum(entry.getValue().size());
}else if(status == 104) {
storage.setStorageNum(-entry.getValue().size());
}
storageReqList.add(storage);
}
updateNum = storageMapper.batchAddStorageNum(storageReqList);
if(updateNum != storageReqList.size()) {
throw new ServiceException(400, "更新库存数量失败!");
}
}
@Override
public void saleSkup(Integer productId, Integer skup) {
checkParamValid(productId, skup);
checkProductStatus(productId);
... ...
... ... @@ -66,9 +66,6 @@ sdk.instanceName=yohopic
yoho.recovery.zkPath=/yh/config/recovery
env.machineId=0
ips.machine=127.0.0.1
wechat.app.partnerid=1218934901
wechat.app.partnerkey=b22de5cfd0ded341e0516505f72649a9
... ... @@ -95,5 +92,16 @@ order.seller.appraiseFee=0.1
order.seller.goodsPaymentRate=0.05
order.seller.earnestMoneyRate=0.2
order.seller.payChannelRate=0.0006
order.buyer.compensate.before_seller_deliver=38
order.buyer.compensate.before_depot_receive=68
order.buyer.cancelWhenSellerDelivery.money=68
order.buyer.cancelWhenSellerUnDelivery.money=38
order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate=0.8
order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate=0.8
uic.url=http://java-yoho-uic.test3.ingress.dev.yohocorp.com/uic
yoho.message.controller.url=http://message-controller.yohoops.org/yoho-message-controller
\ No newline at end of file
... ...
... ... @@ -49,6 +49,7 @@ datasources:
- com.yohoufo.dal.order.TradeBillsMapper
- com.yohoufo.dal.order.OrdersPayTransferMapper
- com.yohoufo.dal.order.ManualTransferMapper
- com.yohoufo.dal.order.MachineIdGenerateMapper
ufo_promotion:
servers:
... ...
... ... @@ -63,9 +63,16 @@ order.seller.appraiseFee=${order.seller.appraiseFee}
order.seller.goodsPaymentRate=${order.seller.goodsPaymentRate}
order.seller.earnestMoneyRate=${order.seller.earnestMoneyRate}
order.seller.payChannelRate=${order.seller.payChannelRate}
order.buyer.compensate.before_depot_receive=${order.buyer.compensate.before_depot_receive}
order.buyer.compensate.before_seller_deliver=${order.buyer.compensate.before_seller_deliver}
order.buyer.cancelWhenSellerDelivery.money=${order.buyer.cancelWhenSellerDelivery.money}
order.buyer.cancelWhenSellerUnDelivery.money=${order.buyer.cancelWhenSellerUnDelivery.money}
order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate=${order.buyer.cancelWhenSellerDelivery.sellerGetMoneyRate}
order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate=${order.buyer.cancelWhenSellerUnDelivery.sellerGetMoneyRate}
erp-gateway.url=${erp-gateway.url}
uic.url=${uic.url}
yoho.message.controller.url=${yoho.message.controller.url}
ips.machine=${ips.machine}
\ No newline at end of file
... ...
... ... @@ -49,6 +49,7 @@ datasources:
- com.yohoufo.dal.order.TradeBillsMapper
- com.yohoufo.dal.order.OrdersPayTransferMapper
- com.yohoufo.dal.order.ManualTransferMapper
- com.yohoufo.dal.order.MachineIdGenerateMapper
ufo_promotion:
servers:
... ...