修复:总平台商品购买后 未成功绑定提货点

This commit is contained in:
wuhui_zzw 2024-04-11 17:01:04 +08:00
parent d607d3066d
commit 7c3cb6158c
5 changed files with 38 additions and 35 deletions

View File

@ -60,23 +60,24 @@ class StoreOrderDao extends BaseDao
* @day 2020/6/16 * @day 2020/6/16
*/ */
public function search(array $where, $sysDel = 0){ public function search(array $where, $sysDel = 0){
$query = StoreOrder::alias('StoreOrder') // $query = StoreOrder::alias('StoreOrder')
->leftJoin('Merchant','Merchant.mer_id = StoreOrder.mer_id') // ->field('StoreOrder.*')
->where(function($query){ // ->leftJoin('Merchant','Merchant.mer_id = StoreOrder.mer_id')
$query->where('Merchant.is_del',0)->whereOr('StoreOrder.mer_id', 0); // ->where(function($query){
}) // $query->where('Merchant.is_del',0)->whereOr('StoreOrder.mer_id', 0);
->when(isset($where['is_trader']) && $where['is_trader'] !== '', function ($query) use ($where) { // })
$query->where('is_trader', $where['is_trader']); // ->when(isset($where['is_trader']) && $where['is_trader'] !== '', function ($query) use ($where) {
}); // $query->where('is_trader', $where['is_trader']);
// $query = StoreOrder::hasWhere('merchant', function ($query) use ($where) {
// if (isset($where['is_trader']) && $where['is_trader'] !== '') {
// $query->where('is_trader', $where['is_trader'])->whereOr('StoreOrder.mer_id', 0);
// }
// $query->where(function($hasQuery){
// $hasQuery->where('is_del',0)->whereOr('StoreOrder.mer_id', 0);
// }); // });
// });
$query = StoreOrder::hasWhere('merchant', function ($query) use ($where) {
if (isset($where['is_trader']) && $where['is_trader'] !== '') {
$query->where('is_trader', $where['is_trader']);
}
$query->where(function($hasQuery){
$hasQuery->where('Merchant.is_del',0)->whereOr('StoreOrder.mer_id', 0);
});
},'*','left');
// 存在商户id是否 判断商户id类型显示对应的订单 30,31,32,33,34 // 存在商户id是否 判断商户id类型显示对应的订单 30,31,32,33,34
if(isset($where['mer_id']) && $where['mer_id'] !== ''){ if(isset($where['mer_id']) && $where['mer_id'] !== ''){
$merchantType = app()->make(MerchantRepository::class) $merchantType = app()->make(MerchantRepository::class)

View File

@ -14,6 +14,7 @@ use app\common\model\store\shipping\Express;
use app\common\model\system\merchant\Merchant; use app\common\model\system\merchant\Merchant;
use app\common\model\user\User; use app\common\model\user\User;
use app\common\repositories\store\MerchantTakeRepository; use app\common\repositories\store\MerchantTakeRepository;
use app\common\repositories\store\PointRepository;
class StoreOrder extends BaseModel class StoreOrder extends BaseModel
{ {
@ -88,9 +89,10 @@ class StoreOrder extends BaseModel
return $this->hasOne(StoreService::class, 'service_id', 'verify_service_id'); return $this->hasOne(StoreService::class, 'service_id', 'verify_service_id');
} }
public function getTakeAttr() public function getTakeAttr(){
{ $pointId = $this->point_id ?? 0;
return app()->make(MerchantTakeRepository::class)->get($this->mer_id); if((int)$pointId > 0) return app()->make(PointRepository::class)->getSearchModel(['id'=>$pointId])->findOrEmpty();
else return app()->make(MerchantTakeRepository::class)->get($this->mer_id);
} }
public function searchDataAttr($query, $value) public function searchDataAttr($query, $value)

View File

@ -1028,7 +1028,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
// 数据补齐 总平台商品订单可能存在部分数据不存在 // 数据补齐 总平台商品订单可能存在部分数据不存在
$merchantCart['commission_rate'] = $merchantCart['commission_rate'] ?? 0; $merchantCart['commission_rate'] = $merchantCart['commission_rate'] ?? 0;
$cost = 0; $cost = 0;
$total_extension_one = 0; $total_extension_one = 0;
$total_extension_two = 0; $total_extension_two = 0;
@ -1150,8 +1149,10 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
'exchange_integral' => $merchantCart['order']['exchange_integral'] ?? 0, 'exchange_integral' => $merchantCart['order']['exchange_integral'] ?? 0,
'wine_diff_money' => $merchantCart['order']['wine_diff_money'] ?? 0, 'wine_diff_money' => $merchantCart['order']['wine_diff_money'] ?? 0,
'wine_diff_money_price' => $merchantCart['order']['wine_diff_money_price'] ?? 0, 'wine_diff_money_price' => $merchantCart['order']['wine_diff_money_price'] ?? 0,
'point_id' => $merchantCart['take']['id'] ?? 0,
]; ];
$allUseCoupon = array_merge($allUseCoupon,$merchantCart['order']['useCouponIds']); $allUseCoupon = array_merge($allUseCoupon,$merchantCart['order']['useCouponIds']);
$orderList[] = $_order; $orderList[] = $_order;
$totalPostage = bcadd($totalPostage,$_order['total_postage'],2); $totalPostage = bcadd($totalPostage,$_order['total_postage'],2);

View File

@ -687,18 +687,17 @@ class StoreOrderRepository extends BaseRepository
$order = $order =
// $this->dao->search($where) // $this->dao->search($where)
$this->dao->getSearch([]) $this->dao->getSearch([])
->hasWhere('merchant',function($query) use ($where){ // ->hasWhere('merchant',function($query) use ($where){
$query->where('is_del',0); // $query->where('is_del',0);
}) // })
->where('order_id',$id) ->where('order_id',$id)
->where('StoreOrder.is_del',0) ->where('is_del',0)
->with($with) ->with($with)
->append(['refund_status','open_receipt']) ->append(['refund_status','open_receipt'])
->find(); ->find();
if (!$order) { if (!$order) return null;
return null;
}
if ($order->activity_type == 2) { if ($order->activity_type == 2) {
if ($order->presellOrder) { if ($order->presellOrder) {
$order->presellOrder->append(['activeStatus']); $order->presellOrder->append(['activeStatus']);
@ -1841,7 +1840,10 @@ class StoreOrderRepository extends BaseRepository
'receipt' => function ($query) { 'receipt' => function ($query) {
return $query->field('order_id,order_receipt_id'); return $query->field('order_id,order_receipt_id');
}, },
])->page($page, $limit)->order('pay_time DESC')->append(['refund_status','open_receipt'])->select(); ])
->page($page, $limit)->order('pay_time DESC')
->append(['refund_status','open_receipt'])
->select();
foreach ($list as $order) { foreach ($list as $order) {
if ($order->activity_type == 2) { if ($order->activity_type == 2) {

View File

@ -192,14 +192,11 @@ class StoreOrder extends BaseController
* @author xaboy * @author xaboy
* @day 2020/6/10 * @day 2020/6/10
*/ */
public function detail($id) public function detail($id){
{
$order = $this->repository->getDetail((int)$id, $this->request->uid()); $order = $this->repository->getDetail((int)$id, $this->request->uid());
if (!$order) if (!$order) return app('json')->fail('订单不存在');
return app('json')->fail('订单不存在'); if ($order->order_type == 1) $order->append(['take', 'refund_status']);
if ($order->order_type == 1) {
$order->append(['take', 'refund_status']);
}
return app('json')->success($order->toArray()); return app('json')->success($order->toArray());
} }