Procházet zdrojové kódy

Merge branch 'master' into linqh-dev

# Conflicts:
#	sql.sql
林琦海 před 5 roky
rodič
revize
d57b393530

+ 39 - 258
app/ghs/controllers/OrderController.php

@@ -2,17 +2,15 @@
 
 namespace ghs\controllers;
 
-use biz\merchant\services\ExpressService;
-use biz\merchant\services\MerchantAssetService;
 use biz\merchant\services\MerchantExtendService;
-use biz\merchant\services\MerchantService;
+use bizGhs\admin\classes\AdminClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\merchant\services\ShopService;
-use biz\order\classes\OrderSendClass;
 use bizGhs\order\classes\OrderClass;
 use bizGhs\order\services\OrderService;
 use biz\saas\services\RegionService;
 use biz\user\services\UserService;
+use bizGhs\product\classes\ProductClass;
 use common\components\configDict;
 use common\components\httpUtil;
 use common\services\xhPayToolService;
@@ -31,88 +29,57 @@ class OrderController extends BaseController
         $post = Yii::$app->request->post();
         $adminId = $this->adminId;
         $shopId = $this->shopId;
-        if(!empty($shopId)){
+        if (!empty($shopId)) {
             //供货商端 员工 开单
             $post['customId'] = $post['customId'] ?? 0;
             $post['adminId'] = $adminId;
             $post['userId'] = 0;
-        }else{
+        } else {
             //供货商端 客户 开单
             $post['userId'] = $adminId;
             $post['adminId'] = 0;
             $post['customId'] = CustomClass::addCustom();
         }
 
-        //零售端口:员工采购
-
         $post['payWay'] = $this->isWx == true ? 0 : 1;
         $post['merchantId'] = $this->merchantId;
         $post['shopId'] = 0;
-        $now = time();
-        $expireTime = $now + 1800;//订单30分钟后过期
-        $post['deadline'] = $expireTime;
+        $post['deadline'] = time() + 1800;//订单30分钟后过期
         $post['fromType'] = 1;//商城
-        $post['prePrice'] = $prePrice;
-        $post['actPrice'] = $actPrice;
+        $post['prePrice'] = 0.01;
+        $post['actPrice'] = 0.01;
+        $post['sendSide'] = $post['sendSide'] ?? 0;
+
+        $productJson = $post['product'] ?? '';
+        if (empty($productJson)) {
+            util::fail('请选择花材');
+        }
+        $productList = json_decode($productJson, true);
+        if (empty($productList)) {
+            util::fail('请选择花材');
+        }
+        $productIds = array_column($productList, 'productId');
+        ProductClass::valid($productIds, $this->merchantId);
+        $post['product'] = $productList;
         $order = OrderClass::addOrder($post);
-        $orderId = $order['id'];
-        $orderSn = $order['orderSn'];
-        //花材商品
-        $itemData = [
-            [
-                'orderId'=>$orderId,
-                'itemId'=>0,
-                'productId'=>0,
-                'unitPrice'=>0.01,
-                'unitNum'=>0,
-                'num'=>0,
-            ],
-        ];
-        //OrderGoodsService::add($data);//创建订单商品列表
-        util::success(['orderSn' => $orderSn, 'totalPrice' => $actPrice]);
+        $orderSn = $order['orderSn'] ?? '';
+        $orderId = $order['id'] ?? 0;
+        util::success([
+            'orderId' => $orderId,
+            'orderSn' => $orderSn,
+            'totalPrice' => 0.01,
+            'sendType' => '快递送',
+            'sendTime' => '15:00',
+            'qrCode' => Yii::$app->params['imgHost'] . '/hhb_small.png',
+        ]);
     }
 
-    //下单要用到的相关信息 shish 2019.12.6
-    public function actionOrderRelate()
+    //延期支付 shish 2021.1.19
+    public function actionDebt()
     {
-        $regionTree = RegionService::tree();
-        $shop = ShopService::getDefaultShop($this->ghs);
-        $freight = MerchantExtendService::getFreight($this->merchantExtend);
-        $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
-        $out = ['freight' => $freight, 'shop' => $shop, 'region' => $regionTree, 'txMapKey' => $mapKey, 'merchant' => $this->ghs];
-        util::success($out);
-    }
-
-    //余额支付 shish 2019.12.6
-    public function actionBalancePay()
-    {
-        $post = Yii::$app->request->post();
-        $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
-        $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
-        $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
-
-        //验证优惠券是否还有效
-        if (!empty($couponId)) {
-            CouponService::checkBeforeUse($couponId, $order['prePrice'], $order['userId']);
-        }
-
-        $order = OrderService::getByOrderSn($orderSn);
-        $userId = $this->adminId;
-        $user = UserService::getUserInfo($userId, false);
-        //验证支付密码是否正确
-        UserService::validPayPassword($payPassword, $user);
-        //支付前验证订单有效性
-        OrderService::checkBeforePay($order, $this->adminId);
-        $typeList = configDict::getConfig('capitalType');
-        $capitalType = $typeList['xhOrder']['id'];
-        $totalFee = $order['prePrice'];
-        $sourceType = 0;
-        $discountData = OrderService::getDiscountPrice(['price' => $totalFee, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
-        $actPrice = $discountData['price'];
-        $callbackParams = [];
-        $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
-        $balance = isset($respond['balance']) ? $respond['balance'] : 0;
-        util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'balance' => $balance]);
+        $get = Yii::$app->request->get();
+        $orderId = $get['orderId'] ?? 0;
+        util::complete();
     }
 
     //获取商城下单要用的微信支付和小程序支付参数 shish 2019.21.3
@@ -122,25 +89,20 @@ class OrderController extends BaseController
         $post = Yii::$app->request->post();
         $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
         $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
-        $order = OrderService::getByOrderSn($orderSn);
+        $order = OrderClass::getByOrderSn($orderSn);
         $orderId = $order['id'];
 
-        //验证优惠券是否还有效
-        if (!empty($couponId)) {
-            CouponService::checkBeforeUse($couponId, $order['prePrice'], $order['userId']);
-        }
-
         //支付前验证订单有效性
-        OrderService::checkBeforePay($order, $this->adminId);
+        OrderClass::valid($order,$this->adminId);
 
         $name = isset($order['orderName']) && !empty($order['orderName']) ? $order['orderName'] : '购买商品';
         $totalFee = $order['actPrice'];
 
         //小程序使用miniOpenId
         if (httpUtil::isMiniProgram()) {
-            $openId = $this->admin['miniOpenId'];
+            $openId = $this->user['miniOpenId'];
         } else {
-            $openId = $this->admin['openId'];
+            $openId = $this->user['openId'];
         }
         $typeList = configDict::getConfig('capitalType');
         $capitalType = $typeList['xhOrder']['id'];
@@ -193,185 +155,4 @@ class OrderController extends BaseController
         util::success($newParams);
     }
 
-    //快捷付款订单
-    public function actionFastPay()
-    {
-        ini_set('date.timezone', 'Asia/Shanghai');
-        $post = Yii::$app->request->post();
-        $payWay = isset($post['payWay']) ? $post['payWay'] : 0;
-        $shopId = !empty($this->shopId) ? $this->shopId : ShopService::getDefaultShopId($this->ghs);
-        //验证门店是否有效
-        $shopInfo = ShopService::getById($shopId);
-        ShopService::valid($shopInfo, $this->merchantId);
-        $post['shopId'] = $shopId;
-        //默认门店订单
-        $store = isset($post['store']) ? $post['store'] : 1;
-        $post['store'] = $store;
-        //来源 0微信 1支付宝 2小程序 3朋友圈 4美团
-        $sourceType = $this->isWx ? 0 : 1;
-        if (httpUtil::isMiniProgram()) {
-            $sourceType = 2;
-        }
-        $sourceType = isset($post['sourceType']) ? $post['sourceType'] : 0;
-        //兼容旧系统sourceType=3表示朋友圈来源
-        $fromType = $sourceType == 3 ? 2 : 0;
-        $fromType = isset($post['fromType']) && !empty($post['fromType']) ? $post['fromType'] : $fromType;
-        $post['userId'] = $this->adminId;
-        $user = $this->admin;
-        $post['bookName'] = isset($user['userName']) ? $user['userName'] : '';
-        $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
-        $bookMobile = empty($bookMobile) && isset($user['mobile']) && !empty($user['mobile']) ? $user['mobile'] : $bookMobile;
-        $post['bookMobile'] = $bookMobile;
-        $prePrice = round($post['prePrice'], 2);
-        $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
-        $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
-        $actPrice = $discountData['price'];
-        $post['discountType'] = $discountData['discountType'];
-        $post['discountAmount'] = $discountData['discountAmount'];
-        $post['actPrice'] = $actPrice;
-        $post['payStyle'] = 0;
-        $post['merchantId'] = $this->merchantId;
-        $now = time();
-        $expireTime = $now + 300;//订单5分钟后过期
-        $post['createTime'] = date("Y-m-d H:i:s", $now);
-        $post['deadline'] = $expireTime;
-        if ($actPrice <= 0) {
-            util::fail('请填写正确的金额');
-        }
-        //微信支付订单提交不能修改价格
-        $post['modPrice'] = $this->isWx ? 0 : 1;
-        $post['sourceType'] = $sourceType;
-        $post['goodsNum'] = 1;
-        $post['fromType'] = $fromType;
-        $order = OrderService::addOrder($post);
-        $orderId = $order['id'];
-        $orderSn = $order['orderSn'];
-        $merchantId = $this->merchantId;
-        if ($payWay == 0) {
-            $orderId = $order['id'];
-            $name = '购买商品';
-            $totalFee = $actPrice;
-            $user = UserService::getById($this->adminId);
-            $openId = isset($user['openId']) ? $user['openId'] : 0;
-            if (httpUtil::isMiniProgram()) {
-                //小程序使用miniOpenId
-                $openId = $user['miniOpenId'];
-            }
-            if (empty($openId)) {
-                util::fail('没有找到客户的openId');
-            }
-            $typeList = configDict::getConfig('capitalType');
-            $capitalType = $typeList['xhOrder']['id'];
-            //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
-            $wxPayType = 0;
-            if (httpUtil::isMiniProgram()) {
-                $wxPayType = 1;
-            }
-            $attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&wxPayType=' . $wxPayType;
-            $wx = Yii::getAlias("@vendor/weixin");
-            require_once($wx . '/lib/WxPay.Api.php');
-            require_once($wx . '/example/WxPay.JsApiPay.php');
-            $input = new \WxPayUnifiedOrder();
-            $input->SetBody($name);
-            $input->SetOut_trade_no($orderSn);
-            $input->SetTotal_fee($totalFee * 100);
-            $input->SetTime_start(date("YmdHis", $now));
-            $input->SetAttach($attach);
-            //设置订单有效期5分钟
-            $input->SetTime_expire(date("YmdHis", $expireTime));
-            $input->SetNotify_url(Yii::$app->params['mallHost'] . '/notice/wx-callback/');
-            $input->SetTrade_type("JSAPI");
-
-            //花卉宝代为申请的微信支付
-            $merchantExtend = $this->merchantExtend;
-            if ($merchantExtend['wxPayApply'] == 1) {
-                $input->SetSub_openid($openId);
-            } else {
-                $input->SetOpenid($openId);
-            }
-            //小程序使用miniAppId
-            if (httpUtil::isMiniProgram()) {
-                $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
-            }
-            Yii::info('支付发起使用小程序信息' . json_encode($merchantExtend));
-            $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
-            $tools = new \JsApiPay();
-            $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
-            $newParams = json_decode($jsApiParameters, true);
-            $newParams['orderId'] = $orderId;
-            util::success($newParams);
-        } elseif ($payWay == 1) {
-            $extend = MerchantExtendService::getByMerchantId($merchantId);
-            if (isset($extend['alipayInit']) == false || $extend['alipayInit'] == 0) {
-                util::fail('支付宝付款即将开通...');
-            }
-            $config = [
-                //应用ID,您的APPID。
-                'app_id' => $extend['alipayPId'],
-                //商户私钥,您的原始格式RSA私钥
-                'merchant_private_key' => $extend['alipayKey'],
-                //异步通知地址
-                'notify_url' => Yii::$app->params['mallHost'] . "/notice/alipay-callback",
-                //同步跳转
-                'return_url' => "",
-                //编码格式
-                'charset' => "UTF-8",
-                //签名方式
-                'sign_type' => "RSA2",
-                //支付宝网关
-                'gatewayUrl' => "https://openapi.alipay.com/gateway.do",
-                //支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
-                'alipay_public_key' => $extend['alipayPublicKey'],
-            ];
-
-            Yii::info(json_encode($config) . ' aplipay config');
-
-            $alipayWap = Yii::getAlias("@vendor/alipayWap");
-            require_once($alipayWap . '/wappay/service/AlipayTradeService.php');
-            require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php');
-
-            $totalFee = $order['actPrice'];
-            $out_trade_no = $orderSn;//商户订单号,商户网站订单系统中唯一订单号,必填
-            $subject = '购买商品';//订单名称,必填
-            $total_amount = $totalFee;//付款金额,必填
-            $body = '';//商品描述,可空
-            $timeout_express = "1m";//超时时间
-
-            $typeList = configDict::getConfig('capitalType');
-            $capitalType = $typeList['xhOrder']['id'];
-            $passbackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&merchantId=' . $merchantId;//将流水类型、优惠卷传过去
-            $passbackParams = urlencode($passbackParams);
-
-            $payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
-            $payRequestBuilder->setBody($body);
-            $payRequestBuilder->setSubject($subject);
-            $payRequestBuilder->setOutTradeNo($out_trade_no);
-            $payRequestBuilder->setTotalAmount($total_amount);
-            $payRequestBuilder->setTimeExpress($timeout_express);
-            //在异步通知时将该参数原样返回
-            $payRequestBuilder->setPassbackParams($passbackParams);
-            //同步通知
-            $returnUrl = Yii::$app->params['mallDomain'] . "/#/pages/callback/success?account={$merchantId}&shopId={$shopId}&orderSn={$orderSn}&totalPrice={$totalFee}&pageStatus=3&payDiscountPrice=0&payDiscountType=0";
-            //异步通知
-            $notifyUrl = Yii::$app->params['mallHost'] . "/notice/alipay-callback";
-            $payResponse = new \AlipayTradeService($config);
-            $result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $notifyUrl);
-            //直接将支付宝的html返回给前端
-            echo $result;
-        } elseif ($payWay == 2) {
-            //余额支付,验证支付密码是否正确
-            $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
-            $user = UserService::getUserInfo($this->adminId, false);
-            UserService::validPayPassword($payPassword, $user);
-            $typeList = configDict::getConfig('capitalType');
-            $capitalType = $typeList['xhOrder']['id'];
-            $callbackParams = [];
-            $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
-            $balance = isset($respond['balance']) ? $respond['balance'] : 0;
-            util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'orderSn' => $orderSn, 'orderId' => $orderId, 'balance' => $balance]);
-        } else {
-            util::fail('无效的支付方式');
-        }
-    }
-
 }

+ 18 - 17
app/shop/controllers/PurchaseController.php

@@ -10,21 +10,22 @@ use common\components\util;
 
 class PurchaseController extends BaseController
 {
-	
-	//生成采购单 shish 2021.1.17
-	public function actionCreateOrder()
-	{
-		$post = Yii::$app->request->post();
-		$ghsShopId = $post['ghsShopId'] ?? 0;
-		$shopId = $this->shopId;
-		$post['shopId'] = $shopId;
-		//判断product数据是不是同个供货商的
-		ProductClass::valid($ids, $ghsShopId);
-		$product = $post['product'] ?? '';
-		$arr = json_decode($product, true);
-		$post['product'] = $arr;
-		PurchaseClass::addPurchase($post);
-		util::complete();
-	}
-	
+
+    //生成采购单 shish 2021.1.17
+    public function actionCreateOrder()
+    {
+        $post = Yii::$app->request->post();
+        $ghsShopId = $post['ghsShopId'] ?? 0;
+        $shopId = $this->shopId;
+        $post['shopId'] = $shopId;
+        $product = $post['product'] ?? '';
+        $arr = json_decode($product, true);
+        //判断product数据是不是同个供货商的
+        $ids = array_column($arr, 'productId');
+        ProductClass::valid($ids, $ghsShopId);
+        $post['product'] = $arr;
+        PurchaseClass::addPurchase($post);
+        util::complete();
+    }
+
 }

+ 12 - 20
biz-ghs/admin/classes/AdminClass.php

@@ -14,19 +14,11 @@ class AdminClass extends BaseClass
 
     public static $baseFile = '\bizGhs\admin\models\Admin';
 
-    //收益通知人
-    public static $noticeAdmin = [
-        //国兰
-        'wx193341a4a80f6ea3' => ['o4c8Vs54PQh32nkgG8R3m4VuGTvw', 'o4c8VszacQJyrzu651CAu0sCsfPc'],
-        //花美灵
-        'wx84d95afcb7b594eb' => ['oTFbYvsjwgVwXggwtlM2ESAKwuN8', 'oTFbYvqP6qwdCCkdFB9GYnlzDIUg'],
-    ];
-
     //未知身份
     CONST IDENTITY_UNKNOWN = 0;
     //客户,花店
     const IDENTITY_CUSTOM = 1;
-    //货商员工
+    //供货商员工
     const IDENTITY_STAFF = 2;
 
     //组合员工基本信息 shish 2019.12.9
@@ -50,26 +42,26 @@ class AdminClass extends BaseClass
         return $list;
     }
 
-    //取员工详情 shish 2019.12.9
-    public static function getDetail($id)
+    //取单个员工详情 shish 2019.12.9
+    public static function getAdminById($id)
     {
-        $detail = self::getById($id);
+        $detail = AdminClass::getById($id);
         if (empty($detail)) {
-            util::fail('没有找到员工信息');
+            util::fail('没有找到员工信息');
         }
         $list = self::groupAdminBaseInfo([$detail]);
         return current($list);
     }
 
-    //获取员工详情 shish 2019.12.9
-    public static function getAdminById($id)
+    //取多个员工信息 shish 2021.1.19
+    public static function getAdminByIds($ids)
     {
-        $detail = AdminClass::getById($id);
-        if (empty($detail)) {
-            util::fail('没有找到员工信息!');
+        $adminList = self::getByIds($ids, null, 'id');
+        if (empty($adminList)) {
+            return [];
         }
-        $list = self::groupAdminBaseInfo([$detail]);
-        return current($list);
+        $adminList = self::groupAdminBaseInfo($adminList);
+        return $adminList;
     }
 
     //添加员工 shish 2019.12.9

+ 1 - 1
biz-ghs/admin/services/AdminService.php

@@ -104,7 +104,7 @@ class AdminService extends BaseService
     //获取员工信息 shish 2019.12.8
     public static function getDetail($id)
     {
-        return AdminClass::getDetail($id);
+        return AdminClass::getAdminById($id);
     }
 
     //获取员工信息 shish 2019.12.8

+ 66 - 197
biz-ghs/order/classes/OrderClass.php

@@ -11,203 +11,72 @@ use bizGhs\base\classes\BaseClass;
 
 class OrderClass extends BaseClass
 {
-	
-	public static $baseFile = '\bizGhs\order\models\Order';
-	
-	
-	//已退款
-	const ORDER_STATUS_REFUND = 6;
-	//完成
-	const ORDER_STATUS_COMPLETE = 5;
-	//已取消
-	const ORDER_STATUS_CANCEL = 4;
-	//待通知
-	const ORDER_STATUS_UN_NOTICE = 3;
-	//配送中
-	const ORDER_STATUS_SENDING = 2;
-	//待配送
-	const ORDER_STATUS_UN_SEND = 1;
-	//待付款
-	const ORDER_STATUS_UN_PAY = 0;
-	//订单总流程数
-	const ORDER_TOTAL_FLOW = 4;
-	
-	//未确认配送方式
-	const SEND_TYPE_UNKNOWN = 0;
-	//自取
-	const SEND_TYPE_NO = 1;
-	//自己送
-	const SEND_TYPE_MYSELF = 2;
-	//代送
-	const SEND_TYPE_OTHER = 3;
-	
-	//送达时间段
-	public static $reachPeriod = [0 => '上午', 1 => '下午', 2 => '晚上'];
-	
-	//优惠金额
-	public static $randDiscount = [
-		50 => [1, 3],
-		100 => [5, 9],
-		300 => [10, 15],
-		500 => [16, 18],
-		1000 => [18, 30],
-		20000 => [90, 100],
-	];
-	
-	//添加订单 shish 2019.12.5
-	public static function addOrder($data)
-	{
-		$date = date("Y-m-d H:i:s");
-		$merchantId = $data['merchantId'] ?? 0;
-		$adminId = $data['adminId'] ?? 0;
-		$data['orderSn'] = orderSn::getGhsOrderSn();
-		$data['payStatus'] = 0;
-		$data['createTime'] = $date;
-		$data['addTime'] = time();
-		
-		$month = date("Ym");
-		$riseNum = StatOrderCountClass::addOrder($month, $merchantId);
-		//将花店每月的总订单数作为编号
-		$data['sendNum'] = $riseNum;
-		$data['totalFlow'] = OrderClass::ORDER_TOTAL_FLOW;
-		$return = self::add($data);
 
-		//全部订单+1,待付款订单+1
-		$merchantAsset = MerchantAssetClass::getByMerchantId($merchantId, true);
-		$merchantAsset->unPayOrder += 1;
-		$merchantAsset->totalOrder += 1;
-		$merchantAsset->save();
+    public static $baseFile = '\bizGhs\order\models\Order';
+
+
+    //已退款
+    const ORDER_STATUS_REFUND = 6;
+    //完成
+    const ORDER_STATUS_COMPLETE = 5;
+    //已取消
+    const ORDER_STATUS_CANCEL = 4;
+    //待通知
+    const ORDER_STATUS_UN_NOTICE = 3;
+    //配送中
+    const ORDER_STATUS_SENDING = 2;
+    //待配送
+    const ORDER_STATUS_UN_SEND = 1;
+    //待付款
+    const ORDER_STATUS_UN_PAY = 0;
+    //订单总流程数
+    const ORDER_TOTAL_FLOW = 4;
+
+    //未确认配送方式
+    const SEND_TYPE_UNKNOWN = 0;
+    //自取
+    const SEND_TYPE_NO = 1;
+    //自己送
+    const SEND_TYPE_MYSELF = 2;
+    //代送
+    const SEND_TYPE_OTHER = 3;
+
+
+    //添加订单 shish 2019.12.5
+    public static function addOrder($data)
+    {
+        $date = date("Y-m-d H:i:s");
+        $merchantId = $data['merchantId'] ?? 0;
+        $month = date("Ym");
+        $data['orderSn'] = orderSn::getGhsOrderSn();
+        $data['payStatus'] = 0;
+        $data['createTime'] = $date;
+        $data['addTime'] = time();
+
+        //花材列表
+        $product = $data['product'];
+        OrderItemClass::batchAdd($product);
+
+        //将花店每月的总订单数作为编号
+        $riseNum = StatOrderCountClass::addOrder($month, $merchantId);
+        $data['sendNum'] = $riseNum;
+        $data['num'] = 1;
+        $data['smallNum'] = 1;
+        $return = self::add($data);
+
+        //全部订单+1,待付款订单+1
+        $merchantAsset = MerchantAssetClass::getByMerchantId($merchantId, true);
+        $merchantAsset->unPayOrder += 1;
+        $merchantAsset->totalOrder += 1;
+        $merchantAsset->save();
+
+        return $return;
+    }
+
+    //根据订单编号查询 shish 2021.19
+    public static function getByOrderSn($orderSn)
+    {
+        return self::getByCondition(['orderSn' => $orderSn]);
+    }
 
-		return $return;
-	}
-	
-	public static function getByOrderSn($orderSn)
-	{
-		return self::getByCondition(['orderSn' => $orderSn]);
-	}
-	
-	//评价 shish 2019.12.16
-	public static function comment($data)
-	{
-		$id = $data['id'];
-		unset($data['id']);
-		return self::updateById($id, $data);
-	}
-	
-	//订单
-	public static function getOrderById($id)
-	{
-		$order = self::getById($id);
-		if (empty($order)) {
-			return [];
-		}
-		$order['goodsInfoList'] = OrderGoodsClass::getGoodsListById($id);
-		return $order;
-	}
-	
-	//根据订单查询 shish 2020.1.4
-	public static function getOrderBySn($orderSn)
-	{
-		$order = self::getByCondition(['orderSn' => $orderSn]);
-		if (empty($order)) {
-			return [];
-		}
-		$id = $order['id'];
-		$order['goodsInfoList'] = OrderGoodsClass::getGoodsListById($id);
-		return $order;
-	}
-	
-	//返回随机优惠金额 shish 2019.9.12
-	public static function getRandDiscount($amount)
-	{
-		if ($amount <= 0) {
-			return 0;
-		}
-		$randDiscount = self::$randDiscount;
-		krsort($randDiscount);
-		$rand = 0;
-		foreach ($randDiscount as $currentAmount => $val) {
-			if ($amount >= $currentAmount) {
-				$rand = rand($val[0], $val[1]);
-				break;
-			}
-		}
-		return $rand / 10;
-	}
-	
-	//订单完成 shish 2020.3.12
-	public static function complete($order, $currentFlow)
-	{
-		$id = $order['id'];
-		self::updateById($id, ['status' => OrderClass::ORDER_STATUS_COMPLETE, 'currentFlow' => $currentFlow]);
-	}
-	
-	//转化出送到时间 shish 2020.3.15
-	public static function getReachTime($order)
-	{
-		$reachTime = '';
-		if (isset($order['reachDate']) && !empty($order['reachDate'])) {
-			$prev = date("n-j", strtotime($order['reachDate']));
-			$periodData = self::$reachPeriod;
-			$periodKey = $order['reachPeriod'];
-			$period = isset($periodData[$periodKey]) ? $periodData[$periodKey] : '上午';
-			$reachTime = $prev . ' ' . $period;
-		}
-		return $reachTime;
-	}
-	
-	//支付成功获取unionId shish 2020.5.12
-	public static function payToUpdateUnionId($merchant, $merchantExtend, $orderSn, $user)
-	{
-		$mcId = $merchantExtend['wxPayMerchantId'];
-		$miniOpenId = isset($user['miniOpenId']) ? $user['miniOpenId'] : '';
-		$unionId = isset($user['unionId']) ? $user['unionId'] : '';
-		$userId = $user['id'];
-		if (empty($unionId)) {
-			$unionId = miniUtil::getPaidUnionId($merchant, $miniOpenId, $mcId, (string)$orderSn, 0);
-			if (!empty($unionId)) {
-				$findUser = UserClass::getByUnionId($unionId);
-				if (empty($findUser)) {
-					UserClass::updateByCondition(['id' => $userId], ['unionId' => $unionId]);
-				} else {
-					UserClass::mergeUser($findUser, $user);
-				}
-			}
-		}
-	}
-	
-	//订单到期未付款的订单置成取消状态 shish 2020.5.25
-	public static function setExpire($order)
-	{
-		$now = time();
-		if (!empty($order['deadline']) && $now > $order['deadline']) {
-			if ($order['status'] == 0) {
-				$id = $order['id'];
-				OrderClass::updateById($id, ['status' => 4]);
-			}
-		}
-	}
-	
-	//支付成功需要处理的流程 shish 2020.5.25
-	public static function payAfter($order, $updateData)
-	{
-		$orderId = $order['id'];
-		$now = time();
-		self::updateById($orderId, $updateData);
-		//发货流程的完成下单
-		OrderSendClass::placeOrder(['orderId' => $orderId, 'payTime' => $now]);
-		$merchantId = $order['merchantId'];
-		$asset = MerchantAssetClass::getByMerchantId($merchantId);
-		//增加订单数
-		StatOrderClass::addOrder($merchantId, $asset);
-		//如果门店和朋友圈订单并且没有填写收花人的直接将订单置为自取并且是完成状态
-		if (isset($order['fromType']) && in_array($order['fromType'], [0, 2])) {
-			if (isset($order['receiveMobile']) && isset($order['receiveAddress'])) {
-				if (empty($order['receiveMobile']) && empty($order['receiveAddress'])) {
-					OrderSendClass::withoutSend($order);
-				}
-			}
-		}
-	}
-	
 }

+ 13 - 0
biz-ghs/order/classes/OrderItemClass.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace bizGhs\order\classes;
+
+use Yii;
+use bizGhs\base\classes\BaseClass;
+
+class OrderItemClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\order\models\OrderItem';
+
+}

+ 15 - 0
biz-ghs/order/models/OrderItem.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace bizGhs\order\models;
+
+use bizGhs\base\models\Base;
+
+class OrderItem extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhGhsOrderItem';
+    }
+
+}

+ 13 - 0
biz-ghs/order/services/OrderItemService.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace bizGhs\order\services;
+
+use bizGhs\base\services\BaseService;
+use Yii;
+
+class OrderItemService extends BaseService
+{
+
+    public static $baseFile = '\bizGhs\order\classes\OrderItemClass';
+
+}

+ 0 - 6
biz-ghs/order/services/OrderService.php

@@ -104,12 +104,6 @@ class OrderService extends BaseService
         }
     }
 
-    //根据编号查询 shish 2019.12.14
-    public static function getByOrderSn($orderSn)
-    {
-        return OrderClass::getByOrderSn($orderSn);
-    }
-
     //点评 shish 2019.12.16
     public static function comment($data)
     {

+ 1 - 1
biz-ghs/shop/services/ShopAdminService.php

@@ -165,7 +165,7 @@ class ShopAdminService extends BaseService
         if (empty($adminId)) {
             util::fail('没有找到员工');
         }
-        $adminInfo = AdminClass::getDetail($adminId);
+        $adminInfo = AdminClass::getAdminById($adminId);
         $adminInfo['shopId'] = isset($relation['shopId']) ? $relation['shopId'] : 0;
         $adminInfo['merchantId'] = isset($relation['merchantId']) ? $relation['merchantId'] : 0;
         $adminInfo['adminId'] = isset($relation['adminId']) ? $relation['adminId'] : 0;

+ 35 - 27
biz/purchase/classes/PurchaseClass.php

@@ -6,36 +6,44 @@ use biz\merchant\classes\ShopClass;
 use biz\order\classes\OrderClass;
 use common\components\orderSn;
 use common\components\stringUtil;
+use common\components\util;
 use Yii;
 use biz\base\classes\BaseClass;
 
 class PurchaseClass extends BaseClass
 {
-	
-	public static $baseFile = '\biz\purchase\models\Purchase';
-	
-	//添加采购 shish 2021.1.18
-	public static function addPurchase($data)
-	{
-		$orderSn = orderSn::getPurchaseSn();
-		$data['orderSn'] = $orderSn;
-		self::add($data);
-		if (isset($data['product']) && !empty($data['product'])) {
-			$productList = $data['product'];
-			foreach ($productList as $key => $product) {
-				$productList[$key]['orderSn'] = $orderSn;
-			}
-			PurchaseItemClass::batchAdd($productList);
-		}
-		
-		//供货商增加订单
-		$ghsShopId = $data['ghsShopId'] ?? 0;
-		$ghsShop = \bizGhs\merchant\classes\ShopClass::getById($ghsShopId);
-		$ghsId = $ghsShop['merchantId'] ?? 0;
-
-		$orderData = [];
-		\bizGhs\order\classes\OrderClass::addOrder($orderData);
-
-	}
-	
+
+    public static $baseFile = '\biz\purchase\models\Purchase';
+
+    //添加采购 shish 2021.1.18
+    public static function addPurchase($data)
+    {
+        $orderSn = orderSn::getPurchaseSn();
+        $data['orderSn'] = $orderSn;
+        self::add($data);
+        if (isset($data['product']) == false || empty($data['product'])) {
+            util::fail('请选择花材');
+        }
+        $productList = $data['product'];
+        foreach ($productList as $key => $product) {
+            $productList[$key]['orderSn'] = $orderSn;
+        }
+        PurchaseItemClass::batchAdd($productList);
+
+        //供货商增加订单
+        $ghsShopId = $data['ghsShopId'] ?? 0;
+        $ghsShop = \bizGhs\merchant\classes\ShopClass::getById($ghsShopId);
+        $ghsId = $ghsShop['merchantId'] ?? 0;
+
+        $orderData = [
+            'prePrice' => 0.01,
+            'actPrice' => 0.01,
+            'num' => 1,
+            'smallNum' => 3,
+            'product' => $productList
+        ];
+        \bizGhs\order\classes\OrderClass::addOrder($orderData);
+
+    }
+
 }

+ 3 - 0
sql.sql

@@ -721,6 +721,9 @@ ALTER TABLE `xhPurchaseItem` CHANGE `price` `totalPrice` DECIMAL(10,2) NOT NULL
 ALTER TABLE `xhPurchaseItem` CHANGE `bigPrice` `price` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '大单位价,每扎价、每包价、每箱价';
 ALTER  TABLE xhPurchaseItem MODIFY `totalPrice` DECIMAL(10,2) NOT NULL DEFAULT '0.00' COMMENT '总价';
 ALTER TABLE xhGhsOrderItem ADD totalPrice DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '总价' AFTER `price`;
+ALTER TABLE xhGhsOrderItem DROP COLUMN `orderId`;
+ALTER TABLE `xhGhsOrder` CHANGE `goodsNum` `num` SMALLINT(4) NOT NULL DEFAULT '0' COMMENT '数量,大单位数量,多少扎,多少箱';
+ALTER TABLE `xhGhsOrder` ADD smallNum SMALLINT NOT NULL DEFAULT 0 COMMENT '小单位数量,多少支,多少块' AFTER `num`;
 
 ===
 ==linqh  21-01-19