修改订单模型
This commit is contained in:
parent
61966cfb8d
commit
ddac26a7e1
@ -42,10 +42,6 @@ class GroupbuyLogic extends Logic
|
||||
])
|
||||
->toArray();
|
||||
|
||||
foreach ($lists['data'] as &$v) {
|
||||
$v['goods_image'] = UrlServer::getFileUrl($v['goods_image']);
|
||||
}
|
||||
|
||||
return ['count'=>$lists['total'], 'lists'=>$lists['data']];
|
||||
|
||||
|
||||
@ -54,6 +50,7 @@ class GroupbuyLogic extends Logic
|
||||
public static function add($post){
|
||||
try{
|
||||
$now = time();
|
||||
$activity_sn = $now.rand(1000, 9999);
|
||||
|
||||
foreach ($post['item'] as $item){
|
||||
$add_data[] =[
|
||||
@ -62,6 +59,7 @@ class GroupbuyLogic extends Logic
|
||||
'activity_price' => $item['price'],
|
||||
'stock'=>$item['stock'],
|
||||
'del' => 1,
|
||||
'activity_sn' =>$activity_sn,
|
||||
'create_time' => $now,
|
||||
'update_time' => $now,
|
||||
];
|
||||
|
||||
@ -112,6 +112,8 @@ class OrderLogic extends Logic
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach ($goods as &$good) {
|
||||
$good['delivery_type'] = !isset($good['delivery_type']) ? OrderEnum::DELIVERY_TYPE_EXPRESS : $good['delivery_type'];
|
||||
}
|
||||
@ -119,6 +121,21 @@ class OrderLogic extends Logic
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
if ($post['order_type'] == 4) {
|
||||
foreach ($goods as $activ) {
|
||||
$isOrder = Db::name('order')->where([
|
||||
'activity_sn' => $activ['activity_sn'],
|
||||
'user_id' => $post['user_id']
|
||||
])
|
||||
->where('order_status', '<>', 4)
|
||||
->find();
|
||||
if($isOrder){
|
||||
throw new Exception('您已抢购过此商品');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 砍价订单验证
|
||||
if (isset($post['bargain_launch_id']) and $post['bargain_launch_id'] > 0) {
|
||||
self::$order_type = OrderEnum::BARGAIN_ORDER;
|
||||
@ -196,23 +213,11 @@ class OrderLogic extends Logic
|
||||
// 订单商品
|
||||
OrderGoods::insertAll($order_goods_datas_insert);
|
||||
|
||||
//处理抢购订单库存
|
||||
//处理抢购逻辑
|
||||
if ($post['order_type'] == 4) {
|
||||
|
||||
foreach ($post['goods'] as $key => $buyVal) {
|
||||
|
||||
$isOrder = Order::alias('o')
|
||||
->join('order_goods og', 'og.order_id = o.id')
|
||||
->where([
|
||||
'og.goods_id' => $buyVal['goods_id'],
|
||||
'o.order_type' => 4,
|
||||
'o.user_id' => $post['user_id']
|
||||
])
|
||||
->where('o.order_status', '<>', '4')->find();
|
||||
|
||||
// if ($isOrder) {
|
||||
// throw new Exception('抢购商品每人只限抢购一次');
|
||||
// }
|
||||
$groupBuy = GroupBuyLogic::isGroupbuy($buyVal['item_id']);
|
||||
|
||||
if (!isset($groupBuy)) {
|
||||
@ -1049,7 +1054,21 @@ class OrderLogic extends Logic
|
||||
$goods_price = self::calculateGoodsPrice($goods, $discount); //商品价格
|
||||
$member_amount = self::memberGoodsPrice($goods, $discount); //会员优惠价格
|
||||
$shipping_price = self::calculateFreight($goods, $address);
|
||||
$activity = 0;
|
||||
if($post['order_type'] == 4){
|
||||
foreach ($goods as $GrItem) {
|
||||
$where = [
|
||||
'item_id'=>$GrItem['item_id'],
|
||||
'status'=>1,
|
||||
'del'=>1
|
||||
];
|
||||
$groupBuy = $groupBuy = GroupbuyGoods::where($where)->find();
|
||||
if(isset($groupBuy)){
|
||||
$activity = $groupBuy['activity_sn'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//计算优惠券优惠的金额
|
||||
$coupon_list_id = 0;
|
||||
$discount_amount = 0;
|
||||
@ -1097,8 +1116,10 @@ class OrderLogic extends Logic
|
||||
$member_amount = $discount_amount = 0;
|
||||
}
|
||||
|
||||
|
||||
$order_data['trade_id'] = $order_id;
|
||||
$order_data['shop_id'] = $shop_id;
|
||||
$order_data['activity_sn'] = $activity;
|
||||
$order_data['user_id'] = $post['user_id'];
|
||||
$order_data['order_sn'] = createSn('order_trade', 't_sn');
|
||||
$order_data['order_type'] = self::$order_type;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user