更新查询
This commit is contained in:
parent
cff6927976
commit
f09ef6dc64
@ -116,15 +116,18 @@ class StoreCartDao extends BaseDao
|
||||
->append(['bc_extension_one', 'bc_extension_two']);
|
||||
},
|
||||
'merchant' => function (Relation $query) use ($uid) {
|
||||
$query->field('mer_id,mer_name,mer_state,mer_avatar,delivery_way,commission_rate,category_id,credit_buy,settle_cycle,interest_rate')->with(['coupon' => function ($query) use ($uid) {
|
||||
$query->where('uid', $uid);
|
||||
},
|
||||
'config' => function ($query) {
|
||||
$query->whereIn('config_key', ['mer_integral_status', 'mer_integral_rate', 'mer_store_stock', 'mer_take_status', 'mer_take_name', 'mer_take_phone', 'mer_take_address', 'mer_take_location', 'mer_take_day', 'mer_take_time']);
|
||||
},
|
||||
'merchantCategory'
|
||||
]);
|
||||
}])->whereIn('cart_id', $ids)->order('product_type DESC,cart_id DESC')->select();
|
||||
$query->field('mer_id,mer_name,mer_state,mer_avatar,delivery_way,commission_rate,category_id')
|
||||
->with([
|
||||
'coupon' => function ($query) use ($uid) {
|
||||
$query->where('uid', $uid);
|
||||
},
|
||||
'config' => function ($query) {
|
||||
$query->whereIn('config_key', ['mer_integral_status', 'mer_integral_rate', 'mer_store_stock', 'mer_take_status', 'mer_take_name', 'mer_take_phone', 'mer_take_address', 'mer_take_location', 'mer_take_day', 'mer_take_time']);
|
||||
},
|
||||
'merchantCategory'
|
||||
]);
|
||||
}])
|
||||
->whereIn('cart_id', $ids)->order('product_type DESC,cart_id DESC')->select();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,8 @@ class StoreCartRepository extends BaseRepository
|
||||
if ($item['merchant']){
|
||||
$merchantData = $item['merchant']->append(['openReceipt'])->toArray();
|
||||
} else {
|
||||
$merchantData = ['mer_id' => 0];
|
||||
throw new ValidateException('商户不存在');
|
||||
// $merchantData = ['mer_id' => 0];
|
||||
}
|
||||
unset($item['merchant']);
|
||||
$coupon_make = app()->make(StoreCouponRepository::class);
|
||||
|
@ -777,9 +777,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'mer_integral_status' => 0,
|
||||
];
|
||||
$allow_no_address = $allow_no_address && $merchantCart['order']['isTake'];
|
||||
// foreach ($merchantCart['config'] as $config) {
|
||||
// $merchantCart['take'][$config['config_key']] = $config['value'];
|
||||
// }
|
||||
foreach ($merchantCart['config'] as $config) {
|
||||
$merchantCart['take'][$config['config_key']] = $config['value'];
|
||||
}
|
||||
$merIntegralConfig = $merchantCart['take'];
|
||||
unset($merchantCart['config']);
|
||||
$merIntegralConfig['mer_integral_rate'] = min(1, $merIntegralConfig['mer_integral_rate'] > 0 ? bcdiv($merIntegralConfig['mer_integral_rate'], 100, 4) : $merIntegralConfig['mer_integral_rate']);
|
||||
|
@ -142,20 +142,26 @@ class StoreOrderRepository extends BaseRepository
|
||||
throw new ValidateException('未开启余额支付');
|
||||
if ($user['now_money'] < $groupOrder['pay_price'])
|
||||
throw new ValidateException('余额不足,请更换支付方式');
|
||||
Db::transaction(function () use ($user, $groupOrder) {
|
||||
$user->now_money = bcsub($user->now_money, $groupOrder['pay_price'], 2);
|
||||
$user->save();
|
||||
$userBillRepository = app()->make(UserBillRepository::class);
|
||||
$userBillRepository->decBill($user['uid'], 'now_money', 'pay_product', [
|
||||
'link_id' => $groupOrder['group_order_id'],
|
||||
'status' => 1,
|
||||
'title' => '购买商品',
|
||||
'number' => $groupOrder['pay_price'],
|
||||
'mark' => '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品',
|
||||
'balance' => $user->now_money
|
||||
]);
|
||||
$this->paySuccess($groupOrder);
|
||||
});
|
||||
Db::startTrans();
|
||||
try{
|
||||
$user->now_money = bcsub($user->now_money, $groupOrder['pay_price'], 2);
|
||||
$user->save();
|
||||
$userBillRepository = app()->make(UserBillRepository::class);
|
||||
$userBillRepository->decBill($user['uid'], 'now_money', 'pay_product', [
|
||||
'link_id' => $groupOrder['group_order_id'],
|
||||
'status' => 1,
|
||||
'title' => '购买商品',
|
||||
'number' => $groupOrder['pay_price'],
|
||||
'mark' => '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品',
|
||||
'balance' => $user->now_money
|
||||
]);
|
||||
$this->paySuccess($groupOrder);
|
||||
Db::commit();
|
||||
}catch (Exception $e) {
|
||||
Db::rollback();
|
||||
throw new ValidateException('余额支付失败');
|
||||
}
|
||||
|
||||
return app('json')->status('success', '余额支付成功', ['order_id' => $groupOrder['group_order_id']]);
|
||||
}
|
||||
|
||||
@ -550,10 +556,13 @@ class StoreOrderRepository extends BaseRepository
|
||||
// 更新调货价格
|
||||
} else if ($cart['product_type'] == '98') {
|
||||
if ($cart['source_id'] > 0) {
|
||||
$price = Db::name('resale')->where('community_id', $cart['source_id'])->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price');
|
||||
if ($price) {
|
||||
return $price;
|
||||
} else {
|
||||
$resale_find = Db::name('resale')->where('community_id', $cart['source_id'])->where('product_attr_unique', $cart['product_attr_unique'])->find();
|
||||
if ($resale_find &&$resale_find['status']==0) {
|
||||
return $resale_find['price'];
|
||||
}else if($resale_find['status']==1){
|
||||
throw new ValidateException('商品已转售');
|
||||
}
|
||||
else {
|
||||
throw new ValidateException('转售商品数据异常');
|
||||
}
|
||||
} else {
|
||||
@ -945,7 +954,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
$param['StoreOrder.paid'] = 1;
|
||||
break; // 已支付
|
||||
case 20:
|
||||
$param['StoreOrder.status'] = 2;
|
||||
$param['StoreOrder.status'] =['in','2,3'];
|
||||
break; // 已收货的商品才可以继续导入
|
||||
default:
|
||||
unset($param['StoreOrder.is_del']);
|
||||
@ -1757,7 +1766,8 @@ class StoreOrderRepository extends BaseRepository
|
||||
if ($status == 1) {
|
||||
$query = $this->dao->search($where)->where($this->getOrderType($status))->whereRaw("(StoreOrder.paid=0 and StoreOrder.pay_type!=8) or (StoreOrder.paid=1 and StoreOrder.pay_type=8 and StoreOrder.status=2)")->where('StoreOrder.is_del', 0);
|
||||
} else {
|
||||
$query = $this->dao->search($where)->where($this->getOrderType($status))->where('StoreOrder.is_del', 0);
|
||||
$arr=$this->getOrderType($status);
|
||||
$query = $this->dao->search($where)->where($arr);
|
||||
}
|
||||
|
||||
$count = $query->count();
|
||||
|
@ -230,6 +230,7 @@ class ProductReplyRepository extends BaseRepository
|
||||
|
||||
public function reply(array $data)
|
||||
{
|
||||
halt(1);
|
||||
$storeOrderProductRepository = app()->make(StoreOrderProductRepository::class);
|
||||
$orderProduct = $storeOrderProductRepository->userOrderProduct($data['order_product_id'], $data['uid']);
|
||||
if (!$orderProduct || !$orderProduct->orderInfo)
|
||||
|
Loading…
x
Reference in New Issue
Block a user