Merge pull request 'feat: 修改订单控制器与列表,增强错误处理与功能,优化代码结构' (#120) from dev into main
Reviewed-on: #120
This commit is contained in:
commit
219f64ec7d
@ -10,6 +10,7 @@ use app\admin\logic\store_order\StoreOrderLogic;
|
||||
use app\admin\validate\store_order\StoreOrderValidate;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\delivery_service\DeliveryService;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
|
||||
|
||||
@ -112,12 +113,12 @@ class StoreOrderController extends BaseAdminController
|
||||
public function refund()
|
||||
{
|
||||
$params = (new StoreOrderValidate())->goCheck('refund');
|
||||
$detail = StoreOrder::where('order_id',$params['order_id'])->findOrEmpty();
|
||||
if(empty($detail)){
|
||||
$detail = StoreOrder::where('order_id', $params['order_id'])->findOrEmpty();
|
||||
if (empty($detail)) {
|
||||
return $this->fail('无该订单请检查');
|
||||
}
|
||||
$res=StoreOrderLogic::refund($detail,$params);
|
||||
if($res==false){
|
||||
$res = StoreOrderLogic::refund($detail, $params);
|
||||
if ($res == false) {
|
||||
return $this->fail('退款失败');
|
||||
}
|
||||
return $this->success('退款成功');
|
||||
@ -126,14 +127,18 @@ class StoreOrderController extends BaseAdminController
|
||||
/**
|
||||
* 设置配送员
|
||||
*/
|
||||
public function set_delivery(){
|
||||
$id=$this->request->post('id');
|
||||
$delivery_uid=$this->request->post('delivery_uid');
|
||||
$res=StoreOrder::where('id',$id)->update(['delivery_uid'=>$delivery_uid]);
|
||||
if($res){
|
||||
public function set_delivery()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$delivery_uid = $this->request->post('delivery_uid');
|
||||
$find = DeliveryService::where('id', $delivery_uid)->find();
|
||||
if(empty($find)){
|
||||
return $this->fail('配送员不存在');
|
||||
}
|
||||
$res = StoreOrder::where('id', $id)->update(['delivery_uid' => $delivery_uid,'delivery_name'=>$find['nickname'],'delivery_id'=>$find['phone']]);
|
||||
if ($res) {
|
||||
return $this->success('设置成功');
|
||||
}
|
||||
return $this->success('设置失败');
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
if($this->request->get('is_delivery')>=1){
|
||||
$this->searchWhere[]=['delivery_uid','>',0];
|
||||
}
|
||||
return StoreOrder::with(['staff','store'])->where($this->searchWhere)
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||
@ -59,7 +62,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$query->whereIn('status', $status);
|
||||
}
|
||||
})
|
||||
->field(['id', 'store_id', 'staff_id', 'order_id', 'paid', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid','refund_status','create_time'])
|
||||
->field(['id', 'store_id', 'staff_id', 'order_id', 'paid', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid','refund_status','create_time','delivery_name','delivery_id'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user