From 13395e424ca82505599e0f0ac823c4138b8ffd61 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 3 Jun 2024 17:49:42 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=95=86=E5=93=81=E6=BA=90=E8=8E=B7=E5=8F=96=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E5=88=97=E8=A1=A8=E7=9A=84API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system_store/SystemStoreController.php | 25 ++++++++++++++++++- .../logic/store_product/StoreProductLogic.php | 24 ++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/app/admin/controller/system_store/SystemStoreController.php b/app/admin/controller/system_store/SystemStoreController.php index bb4badff3..169743b44 100644 --- a/app/admin/controller/system_store/SystemStoreController.php +++ b/app/admin/controller/system_store/SystemStoreController.php @@ -6,6 +6,7 @@ namespace app\admin\controller\system_store; use app\admin\controller\BaseAdminController; use app\admin\lists\system_store\SystemStoreLists; use app\admin\lists\system_store\SystemStoreSourceLists; +use app\admin\logic\store_product\StoreProductLogic; use app\admin\logic\system_store\SystemStoreLogic; use app\admin\validate\system_store\SystemStoreValidate; @@ -39,7 +40,29 @@ class SystemStoreController extends BaseAdminController { return $this->dataLists(new SystemStoreSourceLists()); } - + /** + * @notes 根据商品源获取门店列表 + * @return \think\response\Json + * @author admin + * @date 2024/05/31 17:45 + */ + public function source_product_update_store() + { + $addList=$this->request->post('addList'); + $product_id=$this->request->post('product_id'); + if($addList){ + foreach ($addList as $key=>$value){ + StoreProductLogic::copy($product_id,$value); + } + } + $removeList=$this->request->post('removeList'); + if($removeList){ + foreach ($removeList as $key=>$value){ + StoreProductLogic::store_del($product_id,$value); + } + } + return $this->dataLists(new SystemStoreSourceLists()); + } /** * @notes 添加门店列表 diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 5c3c64476..3fda22b3a 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -114,7 +114,7 @@ class StoreProductLogic extends BaseLogic 'rose' => $params['rose'], ]; if ($params['rose'] > 0) { - $rose_price = bcmul($params['cost'],bcdiv($params['rose'], 100, 2), 2); + $rose_price = bcmul($params['cost'], bcdiv($params['rose'], 100, 2), 2); $data['price'] = bcadd($params['cost'], $rose_price, 2); } else { $data['price'] = 0; @@ -195,7 +195,7 @@ class StoreProductLogic extends BaseLogic /** * 复制商品到门店 */ - public static function copy($id, $store_id,$stock=0) + public static function copy($id, $store_id, $stock = 0) { $find = StoreProduct::where('id', $id)->findOrEmpty()->toArray(); $store_find = StoreBranchProduct::where(['product_id' => $id, 'store_id' => $store_id])->findOrEmpty()->toArray(); @@ -236,4 +236,24 @@ class StoreProductLogic extends BaseLogic } } } + + /** + * 删除门店商品 + */ + public static function store_del($id, $store_id) + { + + Db::startTrans(); + try { + StoreBranchProduct::where(['product_id' => $id, 'store_id' => $store_id])->update(['delete_time' => time()]); + StoreProductAttrValue::where(['product_id' => $id, 'store_id' => $store_id])->update(['delete_time' => time()]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + d($e); + self::setError($e->getMessage()); + return false; + } + } } From 61a274ed4eed3beeb356360dec144b160c914793 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 3 Jun 2024 17:55:16 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E4=BA=86StorePro?= =?UTF-8?q?ductLists=E4=B8=AD=E7=9A=84'purchase'=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/store_product/StoreProductLists.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index d0d12d7e6..f7493f36f 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -45,7 +45,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa public function lists(): array { return StoreProduct::where($this->searchWhere) - ->field(['id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','store_id','bar_code']) + ->field(['id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { From b103582188bfff98d2ccd7fbc3c827f685dbb5cf Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 3 Jun 2024 18:11:07 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=95=86=E5=BA=97=E6=8E=A7=E5=88=B6=E5=99=A8=E4=B8=8E?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E4=B8=8E=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/system_store/SystemStoreController.php | 10 ++++++++-- app/admin/logic/store_product/StoreProductLogic.php | 4 +--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/admin/controller/system_store/SystemStoreController.php b/app/admin/controller/system_store/SystemStoreController.php index 169743b44..e327dc7ec 100644 --- a/app/admin/controller/system_store/SystemStoreController.php +++ b/app/admin/controller/system_store/SystemStoreController.php @@ -52,16 +52,22 @@ class SystemStoreController extends BaseAdminController $product_id=$this->request->post('product_id'); if($addList){ foreach ($addList as $key=>$value){ - StoreProductLogic::copy($product_id,$value); + StoreProductLogic::copy($product_id,$value); + if(StoreProductLogic::hasError()){ + return $this->fail(StoreProductLogic::getError()); + } } } $removeList=$this->request->post('removeList'); if($removeList){ foreach ($removeList as $key=>$value){ StoreProductLogic::store_del($product_id,$value); + if(StoreProductLogic::hasError()){ + return $this->fail(StoreProductLogic::getError()); + } } } - return $this->dataLists(new SystemStoreSourceLists()); + return $this->success('设置成功', [], 1, 1); } /** diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 3fda22b3a..d224e87e7 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -230,7 +230,6 @@ class StoreProductLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); - d($e); self::setError($e->getMessage()); return false; } @@ -246,12 +245,11 @@ class StoreProductLogic extends BaseLogic Db::startTrans(); try { StoreBranchProduct::where(['product_id' => $id, 'store_id' => $store_id])->update(['delete_time' => time()]); - StoreProductAttrValue::where(['product_id' => $id, 'store_id' => $store_id])->update(['delete_time' => time()]); + StoreBranchProductAttrValue::where(['product_id' => $id, 'store_id' => $store_id])->update(['delete_time' => time()]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); - d($e); self::setError($e->getMessage()); return false; } From df785c38c9b4c13a04930477df8c3a708691d18c Mon Sep 17 00:00:00 2001 From: liuchaofu <1873441552@qq.com> Date: Mon, 3 Jun 2024 21:57:23 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 29 ++++----- app/api/logic/order/OrderLogic.php | 63 ++++++++++++-------- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index b8a355635..2e2c2d977 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -114,39 +114,37 @@ class OrderController extends BaseApiController public function createOrder() { - // d(WeChatConfigService::getPayConfigByTerminal(1)); - $user = User::where('id', $this->request->userId)->find(); $cartId = (array)$this->request->post('cart_id', []); - $mer_id = (array)$this->request->post('mer_id', 0); + $store_id = (array)$this->request->post('store_id', 0); $pay_type = (int)$this->request->post('pay_type'); $addressId = (int)$this->request->post('address_id'); $auth_code = $this->request->post('auth_code'); //微信支付条码 $params = $this->request->post(); - if ($mer_id <= 0 && $pay_type != 9) { + if ($store_id <= 0 && $pay_type != 9) { return $this->fail('自提点不能为空'); } if (count($cartId) > 100) { return $this->fail('购物车商品不能超过100个'); } - if ($pay_type == 9 || $pay_type == 17 ||$pay_type==13) { - if (empty($this->request->userInfo['merchant'])) { - return $this->fail('请先绑定商户'); - } - $mer_id = $this->request->userInfo['merchant']['mer_id']; - $params['mer_id'] = $mer_id; - } +// if ($pay_type == 9 || $pay_type == 17 ||$pay_type==13) { +// if (empty($this->request->userInfo['merchant'])) { +// return $this->fail('请先绑定商户'); +// } +// $mer_id = $this->request->userInfo['merchant']['mer_id']; +// $params['mer_id'] = $mer_id; +// } $order = OrderLogic::createOrder($cartId, $addressId, null, $params); if ($order != false) { switch ($pay_type) { case PayEnum::BALANCE_PAY: //余额支付 $user = User::where('id', $this->request->userId)->find(); - $res = OrderLogic::payBalance($user, $order); + OrderLogic::payBalance($user, $order); if (OrderLogic::hasError()) { return $this->fail(OrderLogic::getError()); } else { - $res = OrderLogic::paySuccess($order, ['money' => $order['actual']]); + OrderLogic::paySuccess($order, ['money' => $order['actual']]); if (OrderLogic::hasError()) { return $this->fail(OrderLogic::getError()); } @@ -164,7 +162,6 @@ class OrderController extends BaseApiController return $this->fail(PaymentLogic::getError(), $params); } return $this->success('', $result); - break; case PayEnum::WECHAT_PAY_BARCODE: //微信条码支付 $result = PaymentLogic::codepay($auth_code, $order); @@ -178,7 +175,6 @@ class OrderController extends BaseApiController return $this->success('用户支付中'); } return $this->success('支付成功', ['out_trade_no'=>$result['out_trade_no'],'pay_type'=>PayEnum::WECHAT_PAY_BARCODE,'transaction_id'=>$result['transaction_id']]); - break; case PayEnum::ALIPAY_BARCODE: //支付宝条码支付 $result = PaymentLogic::ali_auth_code($auth_code, $order); @@ -190,11 +186,10 @@ class OrderController extends BaseApiController } $result['create_time'] = $order['create_time']; return $this->success('支付成功', ['out_trade_no'=>$result['out_trade_no'],'pay_type'=>PayEnum::ALIPAY_BARCODE,'transaction_id'=>$result['trade_no']]); - break; default: return $this->fail('支付方式错误'); } - return $this->data(['order_id' => $order->id]); +// return $this->data(['order_id' => $order->id]); } else { return $this->fail(OrderLogic::getError()); } diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 4e830352f..1c4ce05f6 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -12,6 +12,7 @@ use app\common\model\opurchase\Opurchaseinfo; use app\common\model\order\Cart; use app\common\model\retail\Cashierclass; use app\common\model\retail\Cashierinfo; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; @@ -51,15 +52,20 @@ class OrderLogic extends BaseLogic self::$total = 0; /** 计算价格 */ foreach ($cart_select as $k => $v) { - $find = StoreProduct::where(['id' => $v['goods']])->field('store_name,image,unit,price')->find(); + $find = StoreBranchProduct::where(['id' => $v['goods']])->field('store_name,image,unit,price')->find(); if(!$find){ continue; } $cart_select[$k]['total'] = bcmul($v['cart_num'], $find['price'], 2);//钱 $cart_select[$k]['price'] = $find['price']; - $cart_select[$k]['name'] = $find['store_name']; - $cart_select[$k]['imgs'] = $find['image']; - $cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name'); + $cart_select[$k]['product_id'] = $find['goods']; + $cart_select[$k]['old_cart_id'] = implode(',',$cartId); + $cart_select[$k]['cart_num'] = $v['cart_num']; + //理论上每笔都是拆分了 +// $cart_select[$k]['name'] = $find['store_name']; +// $cart_select[$k]['imgs'] = $find['image']; +// $cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name'); + self::$total=bcadd(self::$total, $cart_select[$k]['total'], 2); } $order = [ @@ -67,9 +73,12 @@ class OrderLogic extends BaseLogic 'create_time' => time(), 'order_id' => getNewOrderId('PF'), 'total_price' => self::$total,//总价 + 'pay_price' => self::$total,//后期可能有降价抵扣 'total_num' => count($cart_select),//总数 'pay_type' => $params['pay_type'] ?? 0, 'cart_id' => implode(',', $cartId), + 'store_id'=>$params['store_id'], + 'shipping_type'=>$params['shipping_type']//配送方式 1=快递 ,2=门店自提 // 'delivery_msg'=>' 预计48小时发货 ' ]; } catch (\Exception $e) { @@ -81,7 +90,7 @@ class OrderLogic extends BaseLogic /** * 创建新订单 - * @return Object|bool + * @return Object|bool|array */ static public function createOrder($cartId, $addressId, $user = null, $params = []) { @@ -89,44 +98,46 @@ class OrderLogic extends BaseLogic if(!$orderInfo){ return false; } +// `delivery_name`快递名称/送货人姓名', +// `delivery_code`'快递公司编码', +// `delivery_type` '发货类型', +// `delivery_id'快递单号/手机号', $_order = $orderInfo['order']; + if($orderInfo['order']['shipping_type'] == 1){ + $_order['delivery_name'] = $params['delivery_name']; + $_order['delivery_id'] = $params['delivery_id']; + } $_order['deduction_price'] = 0; - $_order['merchant'] = $params['mer_id']; $_order['uid'] = request()->userId; - $_order['money'] = 0; - $_order['user'] = request()->userId; - $_order['account'] = 0; - $_order['payinfo'] = ''; - $_order['type'] = 0; - $_order['source'] = 0; - $_order['actual'] = $_order['total']; + $user = User::where('id',\request()->userId)->find(); + $_order['real_name'] = $user['real_name']; + $_order['mobile'] = $user['mobile']; + $_order['pay_type'] = $user['pay_type']; + if($addressId>0){ $address=UserAddress::where(['address_id'=>$addressId,'uid'=>Request()->userId])->find(); if($address){ $_order['real_name'] = $address['real_name']; $_order['user_phone'] = $address['phone']; $_order['user_address'] = $address['detail']; - $_order['address_id'] = $addressId; } } - if($params['pay_type']==PayEnum::WECHAT_PAY_BARCODE){ - $_order['source']=1; - } - if($params['pay_type']==PayEnum::CASH_PAY){ - $_order['money']=$_order['total']; - } +// if($params['pay_type']==PayEnum::WECHAT_PAY_BARCODE){ +// $_order['source']=1; +// } +// if($params['pay_type']==PayEnum::CASH_PAY){ +// $_order['money']=$_order['total']; +// } Db::startTrans(); try { $order = StoreOrder::create($_order); $goods_list = $orderInfo['cart_list']; foreach ($goods_list as $k => $v) { - $goods_list[$k]['pid'] = $order->id; - $goods_list[$k]['merchant'] = $params['mer_id']; + $goods_list[$k]['oid'] = $order->id; $goods_list[$k]['uid'] = request()->userId; - $goods_list[$k]['room'] = 0; - $goods_list[$k]['discount'] = 0; - $goods_list[$k]['warehouse'] = 0; - $goods_list[$k]['nums'] = $v['cart_num']; + $goods_list[$k]['cart_id'] = implode(',',$cartId); + $goods_list[$k]['delivery_id'] = $params['store_id'];//商家id + } (new StoreOrderCartInfo())->saveAll($goods_list); $where = ['is_pay' => 0, 'is_del' => 0]; From 522b6ec6a2261e5ebc24f4aed071b3c3c12ae50b Mon Sep 17 00:00:00 2001 From: liuchaofu <1873441552@qq.com> Date: Mon, 3 Jun 2024 22:45:25 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=A0=B8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 16 ++++- app/api/logic/order/OrderLogic.php | 67 ++++++++++++++++++-- app/api/validate/OrderValidate.php | 48 ++++++++++++++ app/common/enum/OrderEnum.php | 8 +++ app/functions.php | 18 ++++++ 5 files changed, 150 insertions(+), 7 deletions(-) create mode 100644 app/api/validate/OrderValidate.php diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 2e2c2d977..40da7fa4d 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -8,6 +8,7 @@ use app\api\logic\order\OrderLogic; use app\api\controller\BaseApiController; use app\api\lists\order\OrderList; use app\api\service\WechatUserService; +use app\api\validate\OrderValidate; use app\common\enum\PayEnum; use app\common\logic\PaymentLogic; use app\common\logic\PayNotifyLogic; @@ -113,7 +114,6 @@ class OrderController extends BaseApiController */ public function createOrder() { - $cartId = (array)$this->request->post('cart_id', []); $store_id = (array)$this->request->post('store_id', 0); $pay_type = (int)$this->request->post('pay_type'); @@ -368,4 +368,18 @@ class OrderController extends BaseApiController return $this->success('添加成功'); } } + + //核销 + public function writeoff_order() + { + $params = (new OrderValidate())->post()->goCheck('check'); + $userId = $this->request->userId; + $res = OrderLogic::writeOff($params,$userId); + if ($res) { + return $this->success('核销成功'); + } + return $this->fail('核销失败'); + } + + } diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 1c4ce05f6..058290c40 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -2,16 +2,12 @@ namespace app\api\logic\order; +use app\common\enum\OrderEnum; use app\common\enum\PayEnum; +use app\common\enum\YesNoEnum; use app\common\logic\BaseLogic; -use app\common\model\goods\Goods; -use app\common\model\goods\Unit; use app\common\model\merchant\Merchant; -use app\common\model\opurchase\Opurchaseclass; -use app\common\model\opurchase\Opurchaseinfo; use app\common\model\order\Cart; -use app\common\model\retail\Cashierclass; -use app\common\model\retail\Cashierinfo; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; @@ -23,6 +19,7 @@ use app\common\model\user\UserAddress; use app\Request; use support\Log; use taoser\exception\ValidateException; +use think\Exception; use think\facade\Db; use Yansongda\Pay\Event\PayEnd; @@ -61,6 +58,7 @@ class OrderLogic extends BaseLogic $cart_select[$k]['product_id'] = $find['goods']; $cart_select[$k]['old_cart_id'] = implode(',',$cartId); $cart_select[$k]['cart_num'] = $v['cart_num']; + $cart_select[$k]['verify_code'] = $params['verify_code']; //理论上每笔都是拆分了 // $cart_select[$k]['name'] = $find['store_name']; // $cart_select[$k]['imgs'] = $find['image']; @@ -94,6 +92,8 @@ class OrderLogic extends BaseLogic */ static public function createOrder($cartId, $addressId, $user = null, $params = []) { + $verify_code = generateUniqueVerificationCode(); + $params['verify_code'] = $verify_code; $orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params); if(!$orderInfo){ return false; @@ -113,6 +113,7 @@ class OrderLogic extends BaseLogic $_order['real_name'] = $user['real_name']; $_order['mobile'] = $user['mobile']; $_order['pay_type'] = $user['pay_type']; + $_order['verify_code'] = $verify_code; if($addressId>0){ $address=UserAddress::where(['address_id'=>$addressId,'uid'=>Request()->userId])->find(); @@ -396,4 +397,58 @@ class OrderLogic extends BaseLogic } return $find; } + + + //核销 + + /** + * @param $params + * @param $uid + * @return bool + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author: codeliu + * @Time: 2024/6/3 22:42 + */ + public static function writeOff($params,$uid): bool + { + $data = StoreOrderCartInfo::where([ + 'oid'=>$params['order_id'], + 'verify_code'=>$params['verify_code'], + 'uid'=>$uid + ])->select()->toArray(); + if (empty($data)){ + return false; + } + Db::startTrans(); + try { + $newArr = []; + $oid = []; + foreach ($data as $k =>$value){ + $oid [] = $value['oid']; + $newArr[$k]['writeoff_time'] = time(); + $newArr[$k]['is_writeoff'] = YesNoEnum::YES; + $newArr[$k]['update_time'] = time(); + } + (new StoreOrderCartInfo())->saveAll($newArr); + $oidArr = array_values(array_unique($oid)); + StoreOrder::whereIn('id',$oidArr) + ->update([ + 'status' => OrderEnum::RECEIVED_GOODS, + 'update_time' => time(), + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + + } + + + + } diff --git a/app/api/validate/OrderValidate.php b/app/api/validate/OrderValidate.php new file mode 100644 index 000000000..ded301cf1 --- /dev/null +++ b/app/api/validate/OrderValidate.php @@ -0,0 +1,48 @@ + 'require|number', + 'verify_code' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'order_id' => '订单', + 'verify_code' => '验证码', + ]; + + + /** + * @notes 添加场景 + * @return OrderValidate + * @author likeadmin + * @date 2024/04/24 10:37 + */ + public function sceneCheck() + { + return $this->only(['order_id','verify_code']); + } + + + +} \ No newline at end of file diff --git a/app/common/enum/OrderEnum.php b/app/common/enum/OrderEnum.php index 0753b46e0..c10fef0c0 100644 --- a/app/common/enum/OrderEnum.php +++ b/app/common/enum/OrderEnum.php @@ -39,6 +39,14 @@ class OrderEnum const EXPENDITURE =0; const INCOME =1; + + /** + * 状态 + * @RECEIVED_GOODS 已收货 + */ + const RECEIVED_GOODS = 2; + + /** * 账户类型 * @USER 用户 diff --git a/app/functions.php b/app/functions.php index 5fddb93e3..90b3db2bf 100644 --- a/app/functions.php +++ b/app/functions.php @@ -342,3 +342,21 @@ if (!function_exists('setUnique')) { } } + + +if (!function_exists('generateUniqueVerificationCode')) { + function generateUniqueVerificationCode() { + // 获取当前时间的毫秒部分 + list($msec, $sec) = explode(' ', microtime()); + $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', ''); + + // 生成一个随机数作为核销码的后缀 + $randomNumber = mt_rand(10000000, 99999999); // 假设核销码是8位数 + + // 将前缀、毫秒时间戳和随机数连接起来 + $type = rand(1, 10); // 生成一个1-10之间的随机数作为前缀 + return $type . $msectime . $randomNumber; + } + +} + From 4dce4f89ae723ebeadb4baaba80c4d61996eb8e0 Mon Sep 17 00:00:00 2001 From: liuchaofu <1873441552@qq.com> Date: Mon, 3 Jun 2024 22:46:52 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 058290c40..a52eafcd8 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -428,6 +428,7 @@ class OrderLogic extends BaseLogic foreach ($data as $k =>$value){ $oid [] = $value['oid']; $newArr[$k]['writeoff_time'] = time(); + $newArr[$k]['id'] = $value['id']; $newArr[$k]['is_writeoff'] = YesNoEnum::YES; $newArr[$k]['update_time'] = time(); }