|
|
|
@ -12,14 +12,13 @@ import com.hfkj.model.order.OrderModel; |
|
|
|
|
import com.hfkj.service.coupon.BsOrderCouponNoService; |
|
|
|
|
import com.hfkj.service.coupon.BsOrderCouponService; |
|
|
|
|
import com.hfkj.service.coupon.channel.HuiLianTongCouponService; |
|
|
|
|
import com.hfkj.service.goods.GoodsMsgService; |
|
|
|
|
import com.hfkj.service.goods.GoodsSpecsService; |
|
|
|
|
import com.hfkj.service.goods.GoodsVpdService; |
|
|
|
|
import com.hfkj.service.goods.*; |
|
|
|
|
import com.hfkj.service.hlt.HuiLianTongUnionCardService; |
|
|
|
|
import com.hfkj.sysenum.GoodsVpdSourceEnum; |
|
|
|
|
import com.hfkj.sysenum.order.OrderChildProductTypeEnum; |
|
|
|
|
import com.hfkj.sysenum.order.OrderChildStatusEnum; |
|
|
|
|
import com.hfkj.sysenum.order.OrderCouponNoStatusEnum; |
|
|
|
|
import com.hfkj.sysenum.order.OrderGoodsStatusEnum; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -40,22 +39,23 @@ import java.math.BigDecimal; |
|
|
|
|
@Component |
|
|
|
|
public class OrderCreateService { |
|
|
|
|
Logger log = LoggerFactory.getLogger(OrderCreateService.class); |
|
|
|
|
@Autowired |
|
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
@Resource |
|
|
|
|
private BsOrderService orderService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BsOrderCouponService orderCouponService; |
|
|
|
|
@Resource |
|
|
|
|
private BsOrderCouponNoService orderCouponNoService; |
|
|
|
|
@Resource |
|
|
|
|
private BsOrderChildService orderChildService; |
|
|
|
|
@Resource |
|
|
|
|
private GoodsMsgService goodsMsgService; |
|
|
|
|
@Resource |
|
|
|
|
private GoodsSpecsService goodsSpecsService; |
|
|
|
|
@Resource |
|
|
|
|
private GoodsVpdService goodsVpdService; |
|
|
|
|
@Resource |
|
|
|
|
private GoodsUserAddressService goodsUserAddressService; |
|
|
|
|
@Resource |
|
|
|
|
private BsOrderGoodsService bsOrderGoodsService; |
|
|
|
|
@Resource |
|
|
|
|
private GoodsShoppingCartService shoppingCartService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 事务产品 |
|
|
|
@ -147,5 +147,70 @@ public class OrderCreateService { |
|
|
|
|
return orderChild; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public OrderChildModel goods(OrderModel order, OrderChildModel orderChild) throws Exception { |
|
|
|
|
// 查询商品
|
|
|
|
|
GoodsMsg goodsMsg = goodsMsgService.queryDetail(orderChild.getProductId()); |
|
|
|
|
if (goodsMsg == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商品"); |
|
|
|
|
} |
|
|
|
|
if (goodsMsg.getStatus() != 1) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, goodsMsg.getTitle()+"暂无法就进行购买"); |
|
|
|
|
} |
|
|
|
|
if (goodsMsg.getType() != 1) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前商品不属于实物产品不可下单!"); |
|
|
|
|
} |
|
|
|
|
// 查询商品规格
|
|
|
|
|
GoodsSpecs goodsSpecs = goodsSpecsService.queryDetail(orderChild.getProductSpecId()); |
|
|
|
|
|
|
|
|
|
if (goodsSpecs == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商品规格"); |
|
|
|
|
} |
|
|
|
|
JSONObject object = (JSONObject) orderChild.getBusiness(); |
|
|
|
|
|
|
|
|
|
orderChild.setMerId(goodsMsg.getMerId()); |
|
|
|
|
orderChild.setProductName(goodsMsg.getTitle()); |
|
|
|
|
orderChild.setProductImg(goodsMsg.getListImg()); |
|
|
|
|
orderChild.setProductSpecName(goodsSpecs.getName()); |
|
|
|
|
orderChild.setProductPrice(goodsSpecs.getSalePrice()); |
|
|
|
|
|
|
|
|
|
if (object == null || object.getLong("deliveryAddressId") == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择收货地址!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询收货地址
|
|
|
|
|
GoodsUserAddress address = goodsUserAddressService.queryDetail(object.getLong("deliveryAddressId")); |
|
|
|
|
if (address == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的收货地址"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 创建卡券订单
|
|
|
|
|
BsOrderGoods orderGoods = new BsOrderGoods(); |
|
|
|
|
orderGoods.setOrderNo(orderChild.getOrderNo()); |
|
|
|
|
orderGoods.setChildOrderNo(orderChild.getChildOrderNo()); |
|
|
|
|
orderGoods.setMerId(orderChild.getMerId()); |
|
|
|
|
orderGoods.setUserId(order.getUserId()); |
|
|
|
|
orderGoods.setUserPhone(order.getUserPhone()); |
|
|
|
|
orderGoods.setGoodsId(goodsMsg.getId()); |
|
|
|
|
orderGoods.setGoodsName(goodsMsg.getTitle()); |
|
|
|
|
orderGoods.setGoodsTypeId(goodsMsg.getGoodsType()); |
|
|
|
|
orderGoods.setGoodsTypeName(goodsMsg.getGoodsTypeName()); |
|
|
|
|
orderGoods.setGoodsBrandId(goodsMsg.getGoodsBrand()); |
|
|
|
|
orderGoods.setGoodsBrandName(goodsMsg.getGoodsBrandName()); |
|
|
|
|
orderGoods.setGoodsSpecsId(goodsSpecs.getId()); |
|
|
|
|
orderGoods.setGoodsSpecsName(goodsSpecs.getName()); |
|
|
|
|
orderGoods.setGoodsSpescOriginalPrice(goodsSpecs.getOriginalPrice()); |
|
|
|
|
orderGoods.setGoodsCount(orderChild.getProductCount()); |
|
|
|
|
orderGoods.setStatus(OrderGoodsStatusEnum.status8.getCode()); |
|
|
|
|
orderGoods.setDeliveryAddress(address.getAddress()); |
|
|
|
|
orderGoods.setDeliveryAddressId(address.getId()); |
|
|
|
|
|
|
|
|
|
bsOrderGoodsService.create(orderGoods); |
|
|
|
|
|
|
|
|
|
if (object.getLong("shopCartId") != null) { |
|
|
|
|
shoppingCartService.delete(object.getLong("shopCartId")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return orderChild; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|