From 053d4fecfebd214adde33b6322c7e17015bcd168 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 11 May 2024 16:50:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operation/OpurchaseclassController.php | 30 +++----- .../operation/OpurchaseclassofferLists.php | 72 +++++++++++++++++++ .../logic/operation/OpurchaseclassLogic.php | 45 +++++++----- app/api/logic/order/OrderLogic.php | 4 +- 4 files changed, 111 insertions(+), 40 deletions(-) create mode 100644 app/admin/lists/operation/OpurchaseclassofferLists.php diff --git a/app/admin/controller/operation/OpurchaseclassController.php b/app/admin/controller/operation/OpurchaseclassController.php index dca6913..fac5883 100644 --- a/app/admin/controller/operation/OpurchaseclassController.php +++ b/app/admin/controller/operation/OpurchaseclassController.php @@ -5,6 +5,7 @@ namespace app\admin\controller\operation; use app\admin\controller\BaseAdminController; use app\admin\lists\operation\OpurchaseclassLists; +use app\admin\lists\operation\OpurchaseclassofferLists; use app\admin\logic\operation\OpurchaseclassLogic; use app\admin\validate\operation\OpurchaseclassValidate; use app\common\model\goods\Goods; @@ -133,24 +134,8 @@ class OpurchaseclassController extends BaseAdminController */ public function goods_offer_list() { - $id = $this->request->get('id'); - $page_no = $this->request->get('page_no', 1); - $params=$this->request->get(); - $where['order_id']=$id; - if(isset($params['is_adopt']) && $params['is_adopt']!==''){ - $where['is_adopt']=$params['is_adopt']; - } - $res = OpurchaseGoodsOffer::where($where)->page($page_no, 25)->select()->each(function ($item) { - $find = Goods::where('id', $item['goods_id'])->with('unitName')->find(); - $item['goods_name'] = $find['name']; - $item['unit_name'] = $find['unit_name']; - $item['supplier_name'] = Supplier::where('id',$item['supplier_id'])->value('mer_name'); - }); - $data['count'] = Opurchaseinfo::where('pid', $id)->count(); - $data['lists'] = $res?->toArray(); - $data['page_no'] = $page_no; - $data['page_siz'] = 15; - return $this->success('ok', $data); + + return $this->dataLists(new OpurchaseclassofferLists()); } /** * @notes 推送给供应商报价 @@ -178,9 +163,12 @@ class OpurchaseclassController extends BaseAdminController public function goods_offer_update() { $id = $this->request->post('id'); - $result = OpurchaseclassLogic::goodsOfferUpdate($id); - if ($result) { - return $this->success('已采纳', [], 1, 1); + $type = $this->request->post('type'); + $notes = $this->request->post('notes'); + $nums = $this->request->post('nums'); + $result = OpurchaseclassLogic::goodsOfferUpdate($id,$type,$notes,$nums); + if ($result==true) { + return $this->success('已设置', [], 1, 1); } return $this->fail(OpurchaseclassLogic::getError()); } diff --git a/app/admin/lists/operation/OpurchaseclassofferLists.php b/app/admin/lists/operation/OpurchaseclassofferLists.php new file mode 100644 index 0000000..eacb0ff --- /dev/null +++ b/app/admin/lists/operation/OpurchaseclassofferLists.php @@ -0,0 +1,72 @@ + ['is_adopt'], + ]; + } + + + /** + * @notes 获取采购供应链商户报价列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/04/27 11:26 + */ + public function lists(): array + { + $where=[]; + return OpurchaseGoodsOffer::where($this->searchWhere) + ->where($where) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function ($item) { + $find = Goods::where('id', $item['goods_id'])->with('unitName')->find(); + $item['goods_name'] = $find['name']; + $item['unit_name'] = $find['unit_name']; + $item['supplier_name'] = Supplier::where('id',$item['supplier_id'])->value('mer_name'); + })->toArray(); + } + + + /** + * @notes 获取采购供应链商户报价数量 + * @return int + * @author likeadmin + * @date 2024/04/27 11:26 + */ + public function count(): int + { + return OpurchaseGoodsOffer::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/operation/OpurchaseclassLogic.php b/app/admin/logic/operation/OpurchaseclassLogic.php index 2426309..25a8072 100644 --- a/app/admin/logic/operation/OpurchaseclassLogic.php +++ b/app/admin/logic/operation/OpurchaseclassLogic.php @@ -92,28 +92,21 @@ class OpurchaseclassLogic extends BaseLogic */ public static function detail($params): array { + $id=$params['id']; $data = Opurchaseclass::findOrEmpty($params['id'])->toArray(); if ($data) { - $data['goods_info'] = Opurchaseinfo::where('pid', $params['id'])->limit(25)->select()->each(function ($item) { + $data['goods_info'] = Opurchaseinfo::where('pid', $params['id'])->limit(25)->select()->each(function ($item)use($id) { $find = Goods::where('id', $item['goods'])->with('unitName')->find(); if ($find) { $item['goods_name'] = $find['name']; $item['unit_name'] = $find['unit_name']; } - // $sys_labels = Goods::where('id', $item['goods'])->value('sys_labels'); - // $supplier_arr=[]; - // if($sys_labels){ - // $arr = explode(',', $sys_labels); - // foreach ($arr as $k => $v) { - // if($v>0){ - // $supplier=Supplier::whereLike('sys_labels', "%," . $v . ",%")->field('id,mer_name')->find(); - // if($supplier){ - // $supplier_arr[]=$supplier; - // } - // } - // } - // } - // $item['supplier'] = array_unique($supplier_arr); + $where=[ + 'goods_id'=>$item['goods'], + 'order_id'=>$id, + 'is_adopt'=>1 + ]; + $item['nums_count']=OpurchaseGoodsOffer::where($where)->sum('nums'); }); $data['merchant_name'] = Merchant::where('mer_id', $data['merchant'])->value('mer_name'); @@ -198,11 +191,27 @@ class OpurchaseclassLogic extends BaseLogic * @return bool * @date 2024/04/27 11:26 */ - public static function goodsOfferUpdate($params) + public static function goodsOfferUpdate($id,$type=0,$notes='',$nums=0) { try { - OpurchaseGoodsOffer::where('id', $params)->update(['is_adopt' => 1]); - return true; + $find=OpurchaseGoodsOffer::where('id', $id)->find(); + if($type==0){ + if($find &&$find['price']==0){ + self::setError('报价未设置'); + return false; + } + $find->is_adopt=1; + }else{ + $find->is_storage=1; + $find->notes=$notes; + $find->before_nums=$find->nums; + $find->nums=$nums; + } + $res= $find->save(); + if($res){ + return true; + } + return false; } catch (\Exception $e) { self::setError($e->getMessage()); return false; diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index a428860..a693c12 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -74,7 +74,9 @@ class OrderLogic extends BaseLogic static public function createOrder($cartId, $addressId, $user = null, $params = []) { $orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params); - + if(!$orderInfo){ + return false; + } $_order = $orderInfo['order']; $_order['deduction_price'] = 0; $_order['merchant'] = $params['mer_id']; From a7504f3660390583194cf82019b01ba008326081 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 11 May 2024 17:02:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/RetailOrderController.php | 8 ++++---- config/thinkorm.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/api/controller/order/RetailOrderController.php b/app/api/controller/order/RetailOrderController.php index d92845e..8fb583a 100644 --- a/app/api/controller/order/RetailOrderController.php +++ b/app/api/controller/order/RetailOrderController.php @@ -95,18 +95,18 @@ class RetailOrderController extends BaseApiController $order = OrderLogic::createOrder($cartId, $addressId, null, $params); if ($order != false) { switch ($pay_type) { - case PayEnum::WECHAT_PAY: + case PayEnum::BALANCE_PAY: //余额支付 $user = User::where('id', $this->request->userId)->find(); $res = RetailOrderLogic::payBalance($user, $order); if (RetailOrderLogic::hasError()) { + return $this->fail(RetailOrderLogic::getError()); + } else { $res = RetailOrderLogic::paySuccess($order, ['money' => $order['actual']]); if (RetailOrderLogic::hasError()) { - } else { return $this->fail(RetailOrderLogic::getError()); } - } else { - return $this->fail(RetailOrderLogic::getError()); + return $this->success('余额支付成功'); } break; case PayEnum::WECHAT_PAY: diff --git a/config/thinkorm.php b/config/thinkorm.php index 77eb1a6..9be215f 100644 --- a/config/thinkorm.php +++ b/config/thinkorm.php @@ -23,7 +23,7 @@ return [ // 断线重连 'break_reconnect' => true, // 关闭SQL监听日志 - 'trigger_sql' => true, + 'trigger_sql' => false, // 自定义分页类 'bootstrap' => '' ],