shish 4 жил өмнө
parent
commit
79d4c9ef3f

+ 2 - 2
app-ghs/controllers/OrderController.php

@@ -268,7 +268,7 @@ class OrderController extends BaseController
             require_once($wx . '/example/WxPay.MicroPay.php');
 
             //获取微信商户号等信息
-            $sjExtend = WxOpenClass::getWxInfo();
+            $sjExtend = WxOpenClass::getGhsWxInfo();
 
             $microPay = new \MicroPay();
             $payReturn = $microPay->query($orderSn, $sjExtend);
@@ -441,7 +441,7 @@ class OrderController extends BaseController
             $input->SetOut_trade_no($orderSn);
 
             //获取微信商户号等信息
-            $sjExtend = WxOpenClass::getWxInfo();
+            $sjExtend = WxOpenClass::getGhsWxInfo();
 
             $microPay = new \MicroPay();
             $res = $microPay->pay($input, $sjExtend);

+ 8 - 61
app-hd/controllers/OrderController.php

@@ -15,8 +15,10 @@ use bizHd\order\services\OrderService;
 use bizHd\saas\services\RegionService;
 use bizHd\user\services\UserService;
 use bizGhs\order\classes\OrderItemClass;
+use bizHd\wx\classes\WxOpenClass;
 use common\components\dict;
 use common\components\dateUtil;
+use common\components\payUtil;
 use common\services\xhPayToolService;
 use Yii;
 use common\components\util;
@@ -36,29 +38,15 @@ class OrderController extends BaseController
     //微信和支付宝付款码支付 ssh 2021.4.11
     public function actionCodePay()
     {
-        $get = Yii::$app->request->get();
-        util::success($get);
-/*
-
         ini_set('date.timezone', 'Asia/Shanghai');
         header("Content-type: text/html; charset=utf-8");
         $get = Yii::$app->request->get();
         $id = isset($get['id']) ? $get['id'] : 0;
         $order = OrderClass::getById($id, true);
-        if (isset($order->status) == false || $order->status != 1) {
-            util::fail('不是待付款订单');
-        }
-        OrderClass::valid($order, $this->shopId);
-        $cgId = $order->purchaseId ?? 0;
-        $cg = PurchaseClass::getById($cgId, true);
-        $orderSn = $cg->orderSn ?? '';
-        if (empty($orderSn)) {
-            util::fail('没有找到采购单');
-        }
-        //付款码
+        OrderClass::valid($order, $this->mainId);
         $authCode = (string)$get['authCode'] ?? '';
         if (empty($authCode)) {
-            util::fail('支付失败');
+            util::fail('没有获取到支付码');
         }
         $wxPrefix = ['10', '11', '12', '13', '14', '15'];
         $isWx = false;
@@ -67,26 +55,19 @@ class OrderController extends BaseController
                 $isWx = true;
             }
         }
-        $deadline = $cg->deadline;
-        $current = date("Y-m-d H:i:s");
-        if ((strtotime($deadline) + 20) < strtotime($current)) {
-            util::fail('订单已经失效');
-        }
-        $totalFee = $cg->actPrice ?? 0;
-
+        $orderSn = $order->orderSn ?? '';
         $outTradeNo = $orderSn;
         $subject = '购买商品';
+        $totalFee = $order->orderPrice ?? 0;
         $totalAmount = $totalFee;
         $body = "门店";
-        $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
+        $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
 
         if ($isWx) {
 
             $wxPayWay = dict::getDict('payWay', 'wxPay');
             $order->payWay = $wxPayWay;
             $order->save();
-            $cg->payWay = $wxPayWay;
-            $cg->save();
 
             $wx = Yii::getAlias("@vendor/wxPayApi_v3.0.10");
             require_once($wx . '/lib/WxPay.Api.php');
@@ -105,27 +86,10 @@ class OrderController extends BaseController
             $res = $microPay->pay($input, $sjExtend);
             if (isset($res["return_code"]) && $res["return_code"] == "SUCCESS" && isset($res["result_code"]) && $res["result_code"] == 'SUCCESS') {
                 $transactionId = $res['transaction_id'] ?? '';
-                $openId = $res['openid'] ?? '';
-                $aliUserId = '';
-
-                $cg->onlinePay = dict::getDict('onlinePay', 'yes');
-                $cg->codePay = 1;
-                $cg->payOpenId = $openId;
-                $cg->aliUserId = $aliUserId;
-                //自取订单
-                $cg->getType = PurchaseClass::GET_TYPE_SELF_GET;
-                $cg->save();
-
                 $order->onlinePay = dict::getDict('onlinePay', 'yes');
-                $order->codePay = 1;
-                //自取订单
-                $order->sendType = OrderClass::SEND_TYPE_NO;
                 $order->save();
-
                 $attach = '';
                 payUtil::thirdPay($wxPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
-
-
                 util::success(['returnStatus' => 'SUCCESS']);
             } else {
                 Yii::info(json_encode($res));
@@ -145,8 +109,6 @@ class OrderController extends BaseController
             $aliPayWay = dict::getDict('payWay', 'alipay');
             $order->payWay = $aliPayWay;
             $order->save();
-            $cg->payWay = $aliPayWay;
-            $cg->save();
 
             $aliF2F = Yii::getAlias("@vendor/alipayF2F");
             require_once($aliF2F . '/f2fpay/model/builder/AlipayTradePayContentBuilder.php');
@@ -195,24 +157,9 @@ class OrderController extends BaseController
 
             if ($barPayResult->getTradeStatus() == 'SUCCESS') {
                 $respond = $barPayResult->getResponse();
-                $openId = '';
-                $aliUserId = $respond->buyer_user_id ?? '';
                 $transactionId = $respond->trade_no ?? '';
-
-                $cg->onlinePay = dict::getDict('onlinePay', 'yes');
-                $cg->codePay = 1;
-                $cg->payOpenId = $openId;
-                $cg->aliUserId = $aliUserId;
-                //自取订单
-                $cg->getType = PurchaseClass::GET_TYPE_SELF_GET;
-                $cg->save();
-
                 $order->onlinePay = dict::getDict('onlinePay', 'yes');
-                $order->codePay = 1;
-                //自取订单
-                $order->sendType = OrderClass::SEND_TYPE_NO;
                 $order->save();
-
                 $attach = '';
                 payUtil::thirdPay($aliPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
 
@@ -220,7 +167,7 @@ class OrderController extends BaseController
             }
             util::success(['returnStatus' => 'FAILURE']);
         }
-*/
+
     }
 
     //开单操作 ssh 20220316

+ 8 - 0
biz-hd/order/classes/OrderClass.php

@@ -65,6 +65,14 @@ class OrderClass extends BaseClass
         20000 => [90, 100],
     ];
 
+    public static function valid($order, $mainId)
+    {
+        if (isset($order->mainId) == false || $order->mainId != $mainId) {
+            util::fail('没有权限访问的订单');
+        }
+        return true;
+    }
+
     //添加订单 ssh 2019.12.5
     public static function addOrder($data)
     {

+ 19 - 1
sql.txt

@@ -868,4 +868,22 @@ ALTER TABLE xhGhsItem DROP INDEX `uni_index_product`;
 
 ====花材表的mainId添加进去之后,唯一的索引id最好也要加进去 ssh 20220418
 
-ALTER TABLE xhWorkItem ADD unitPrice DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '当前单位售价' AFTER `unitName`;
+ALTER TABLE xhWorkItem ADD unitPrice DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '当前单位售价' AFTER `unitName`;
+
+ALTER TABLE xhOrder ADD goodsPrice DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '花材商品金额' AFTER `capitalId`;
+ALTER TABLE xhOrder MODIFY `sendCost` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '运费' AFTER `goodsPrice`;
+ALTER TABLE xhOrder MODIFY `labourCost` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '人工和资材费用' AFTER `sendCost`;
+ALTER TABLE xhOrder MODIFY `prePrice` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '原价=花材金额+运费+人工成本' AFTER `labourCost`;
+ALTER TABLE xhOrder MODIFY `discountType` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '优惠类型 1没有优惠 2使用平台优惠。类型放在dict.php里' AFTER `prePrice`;
+ALTER TABLE xhOrder MODIFY `discountAmount` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '优惠金额' AFTER `discountType`;
+
+ALTER TABLE xhOrder ADD `orderPrice` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '订单金额 = 原价扣除优惠,不受退款影响' AFTER `discountAmount`;
+ALTER TABLE xhOrder ADD `refundPrice` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '最后一次的退款金额' AFTER `orderPrice`;
+ALTER TABLE xhOrder ADD `tkPrice` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '累计退款金额' AFTER `refundPrice`;
+
+ALTER TABLE xhOrder MODIFY `actPrice` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '实付金额 (原价扣除优惠、退款 prePrice - discountAmount - tkPrice) actPrice realPrice作用现在一样' AFTER `tkPrice`;
+ALTER TABLE xhOrder MODIFY `realPrice` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '实付金额 (原价扣除优惠、退款 prePrice - discountAmount - tkPrice) actPrice realPrice作用现在一样' AFTER `actPrice`;
+ALTER TABLE xhOrder ADD `debtPrice` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '总欠款金额' AFTER `realPrice`;
+ALTER TABLE xhOrder ADD `remainDebtPrice` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '剩余欠款金额' AFTER `debtPrice`;
+
+===零售订单优化 ssh 20220422