Browse Source

清算与回调

shish 5 years ago
parent
commit
29aba55302

+ 5 - 0
app-hd/controllers/NoticeController.php

@@ -4,6 +4,7 @@ namespace hd\controllers;
 
 use biz\recharge\classes\RechargeClass;
 use bizHd\purchase\classes\PurchaseClass;
+use bizHd\purchase\classes\PurchaseClearClass;
 use common\components\dict;
 use Yii;
 use common\components\util;
@@ -140,6 +141,10 @@ class NoticeController extends PublicController
                 //采购订单
                 PurchaseClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
                 break;
+            case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
+                //采购订单结算
+                PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                break;
             default:
         }
     }

+ 33 - 20
app-hd/controllers/PurchaseClearController.php

@@ -16,8 +16,23 @@ class PurchaseClearController extends BaseController
     public function actionCreateOrder()
     {
         $post = Yii::$app->request->post();
+        $current = time();
+        $list = PurchaseClearClass::getAllByCondition(['shopId' => $this->shopId, 'status' => PurchaseClearClass::STATUS_AWAIT_PAY], null, '*', null, true);
+        if (!empty($list)) {
+            foreach ($list as $item) {
+                $deadline = $item->deadline;
+                $deadTime = strtotime($deadline);
+                if ($current > $deadTime) {
+                    $item->status = PurchaseClearClass::STATUS_EXPIRE;
+                    $item->save();
+                } else {
+                    util::fail('您还有结算订单没有付款');
+                }
+            }
+        }
         $ids = $post['id'];
-        $data['merchantId'] = $this->sjId;
+        $data['sjId'] = $this->sjId;
+        $data['shopId'] = $this->shopId;
         $data['id'] = $ids;
         $respond = PurchaseClearClass::addClear($data);
         util::success($respond);
@@ -29,28 +44,28 @@ class PurchaseClearController extends BaseController
         $post = Yii::$app->request->post();
         $couponId = $post['couponId'] ?? 0;
         $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
-        $order = PurchaseClearClass::getByCondition(['orderSn' => $orderSn]);
+        $order = PurchaseClearClass::getByCondition(['orderSn' => $orderSn], true);
         if (empty($order)) {
             util::fail('订单号无效');
         }
-        $id = $order['id'];
-
-        $name = '1123';
-        $totalFee = $order['actPrice'];
-
+        $current = time();
+        $deadline = $order->deadline;
+        if ($current > strtotime($deadline)) {
+            $order->status = PurchaseClearClass::STATUS_EXPIRE;
+            $order->save();
+            util::fail('订单已经失效,请重新发起结算');
+        }
+        $name = '采购单结算';
+        $totalFee = $order->actPrice;
         //强制使用小程序的miniOpenId
         $openId = $this->admin['miniOpenId'];
-
-        $capitalType = dict::getDict('capitalType','xhPurchase','id');
-        //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
-        $wxPayType = 0;
-        if (httpUtil::isMiniProgram()) {
-            $wxPayType = 1;
-        }
+        $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
+        //小程序支付
+        $wxPayType = 1;
         $attach = "couponId=" . $couponId . "&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType;
         //订单30分钟后过期
-        $now = time();
-        $expireTime = $now + 1800;
+
+        $expireTime = $current + 1800;
 
         $wx = Yii::getAlias("@vendor/weixin");
         require_once($wx . '/lib/WxPay.Api.php');
@@ -59,7 +74,7 @@ class PurchaseClearController extends BaseController
         $input->SetBody($name);
         $input->SetOut_trade_no($orderSn);
         $input->SetTotal_fee($totalFee * 100);
-        $input->SetTime_start(date("YmdHis", $now));
+        $input->SetTime_start(date("YmdHis", $current));
         $input->SetAttach($attach);//将流水类型、代金劵等传给微信再回传
         $input->SetTime_expire(date("YmdHis", $expireTime));
         $input->SetNotify_url(Yii::$app->params['hdHost'] . '/notice/wx-callback/');
@@ -81,9 +96,7 @@ class PurchaseClearController extends BaseController
         $tools = new \JsApiPay();
         $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
         $newParams = json_decode($jsApiParameters, true);
-        $current = date("Y-m-d H:i:s");
-        $updateData = ['deadline' => $current, 'changePrice' => 2];
-        PurchaseClearClass::updateById($id, $updateData);
+
         util::success($newParams);
     }
 

+ 74 - 2
biz-hd/purchase/classes/PurchaseClearClass.php

@@ -4,20 +4,92 @@ namespace bizHd\purchase\classes;
 
 use bizHd\base\classes\BaseClass;
 use common\components\orderSn;
+use common\components\util;
+use Yii;
 
 class PurchaseClearClass extends BaseClass
 {
 
     public static $baseFile = '\bizHd\purchase\models\PurchaseClear';
 
+    const STATUS_AWAIT_PAY = 1;
+    const STATUS_HAS_PAY = 2;
+    const STATUS_EXPIRE = 3;
+
     public static function addClear($data)
     {
         $orderSn = orderSn::getPurchaseClearSn();
-        $data['actPrice'] = 0.01;
+        $ids = $data['id'];
+        $arr = explode(',', $ids);
+        if (empty($arr)) {
+            util::fail('请选择采购单');
+        }
+        $purchaseList = PurchaseClass::getAllByCondition(['id' => ['in', $arr]], null, ['id', 'actPrice', 'debt'], null, true);
+        if (empty($purchaseList)) {
+            util::fail('请选择采购单');
+        }
+        $totalPrice = 0;
+        foreach ($purchaseList as $purchase) {
+            if ($purchase->debt != PurchaseClass::DEBT_YES) {
+                util::fail('请选择有欠款的采购单');
+            }
+            $totalPrice = bcadd($totalPrice, $purchase->actPrice, 2);
+        }
+        $data['actPrice'] = $totalPrice;
+        $data['prePrice'] = $totalPrice;
         $data['orderSn'] = $orderSn;
-        $data['purchaseIds'] = $data['id'];
+        $data['purchaseIds'] = $ids;
+        $deadTime = time() + 120;
+        $data['deadline'] = date("Y-m-d H:i:s", $deadTime);
         unset($data['id']);
         return self::add($data);
     }
 
+    //第三方支付回调 shish 2021.4.28
+    public static function thirdPay($payWay, $orderSn, $totalFee, $attach)
+    {
+        $info = self::getByCondition(['orderSn' => $orderSn], true);
+        if (empty($info)) {
+            $msg = "没有找到清算订单 orderSn:{$orderSn}";
+            Yii::info($msg);
+            util::fail($msg);
+        }
+        if ($info->actPrice != $totalFee) {
+            $msg = "清算订单金额与回调通知金额不一致 orderSn:{$orderSn} {$info->actPrice} {$totalFee}";
+            Yii::info($msg);
+            util::fail($msg);
+        }
+        self::complete($info, $payWay);
+    }
+
+    //支付成功后的流程 shish 2021.4.28
+    public static function complete($order, $payWay)
+    {
+        if (empty($order)) {
+            util::fail('没有找到订单');
+        }
+        if (isset($order->status) == false || $order->status != self::STATUS_AWAIT_PAY) {
+            util::fail('订单不是待付款状态');
+        }
+        $order->status = self::STATUS_HAS_PAY;
+        $order->save;
+        $orderSn = $order->orderSn;
+        $ids = $order->purchaseIds;
+        $arr = explode(',', $ids);
+        if (empty($arr)) {
+            $msg = "结算订单 orderSn:{$orderSn} 支付成功,回调处理,没有找到采购订单";
+            util::fail($msg);
+        }
+        $list = PurchaseClass::getAllByCondition(['id' => ['in', $arr]], null, '*', null, true);
+        if (empty($list)) {
+            $msg = "结算订单 orderSn:{$orderSn} 支付成功,回调处理,没有找到采购订单!";
+            util::fail($msg);
+        }
+        foreach ($list as $purchase) {
+            $purchase->debt = 2;
+            $purchase->payWay = $payWay;
+            $purchase->save();
+        }
+    }
+
 }

+ 164 - 164
common/base/classes/BaseClass.php

@@ -6,168 +6,168 @@ use Yii;
 
 class BaseClass
 {
-	
-	public static $baseFile;
-	
-	//查询全部 ssh 2019.11.27
-	public static function getAllList($select, $where, $order = '', $with = '')
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		$return = $model->getAllList($select, $where, $order, $with);
-		return $return;
-	}
-	
-	//分页查询 ssh 2019.9.21
-	public static function getList($select, $where, $order = '', $with = '')
-	{
-		$get = Yii::$app->request->get();
-		$page = isset($get['page']) ? $get['page'] : 1;
-		Yii::$app->params['page'] = $page;
-		$pageSize = isset($get['pageSize']) && !empty($get['pageSize']) ? $get['pageSize'] : Yii::$app->params['pageSize'];
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		$return = $model->getList($select, $where, $page, $pageSize, $order, $with);
-		return $return;
-	}
-	
-	//查询指定条数 ssh 2019.11.30
-	public static function getLimitList($select, $where, $limit = 10, $order = '', $with = '')
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		$return = $model->getLimitList($select, $where, $limit, $order, $with);
-		return $return;
-	}
-	
-	public static function add($data, $returnObject = false)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->add($data, $returnObject);
-	}
-	
-	/**
-	 * 批量添加
-	 */
-	public static function batchAdd($data)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		$model->batchAdd($data);
-	}
-	
-	/**
-	 * 根据主键ID删除一条记录
-	 */
-	public static function deleteById($id)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->deleteById($id);
-	}
-	
-	/**
-	 *根据条件删除一条或多条记录
-	 */
-	public static function deleteByCondition($condition)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		$count = $model->deleteByCondition($condition);
-		return $count;
-	}
-	
-	//根据id批量删 ssh 2019.12.7
-	public static function deleteByIds($ids)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->deleteByIds($ids);
-	}
-	
-	/**
-	 * 根据主键ID更新一条记录
-	 */
-	public static function updateById($id, $data)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->updateById($id, $data);
-	}
-
-	//根据多个主键id更新 ssh 2019.9.3
-	public static function updateByIds($ids, $data)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->updateByIds($ids, $data);
-	}
-	
-	/**
-	 * 根据条件更新一条或多条记录
-	 */
-	public static function updateByCondition($condition, $data)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		$count = $model->updateByCondition($condition, $data);
-		return $count;
-	}
-	
-	/**
-	 * 根据主键ID查出一条记录
-	 */
-	public static function getById($id, $returnObject = false)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->getById($id, $returnObject);
-	}
-	
-	//随机取一个 ssh 2020.2.10
-	public static function getOne($returnObject = false, $order = false)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->getOne($returnObject, $order);
-	}
-	
-	/**
-	 *根据条件查出一条记录
-	 */
-	public static function getByCondition($condition, $returnObject = false, $order = false)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->getByCondition($condition, $returnObject, $order);
-	}
-	
-	//是否存在  ssh 2019.8.30
-	public static function exists($condition)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->exists($condition);
-	}
-	
-	/**
-	 *根据条件查出多条记录
-	 */
-	public static function getAllByCondition($condition, $order = null, $field, $indexBy = null)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->getAllByCondition($condition, $order, $field, $indexBy);
-	}
-	
-	/**
-	 * 根据多个主键ID查询多条记录
-	 */
-	public static function getByIds($ids, $order = null, $indexBy = null)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->getByIds($ids, $order, $indexBy);
-	}
-	
-	/**
-	 *根据条件查出数量
-	 */
-	public static function getCount($condition)
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->getCount($condition);
-	}
-	
-	//计数器+1-1 shizq 2019-12-05
-	public static function counters($counters, $condition, $params = [])
-	{
-		$model = Yii::createObject(['class' => static::$baseFile]);
-		return $model->counters($counters, $condition, $params);
-	}
-	
+
+    public static $baseFile;
+
+    //查询全部 ssh 2019.11.27
+    public static function getAllList($select, $where, $order = '', $with = '')
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        $return = $model->getAllList($select, $where, $order, $with);
+        return $return;
+    }
+
+    //分页查询 ssh 2019.9.21
+    public static function getList($select, $where, $order = '', $with = '')
+    {
+        $get = Yii::$app->request->get();
+        $page = isset($get['page']) ? $get['page'] : 1;
+        Yii::$app->params['page'] = $page;
+        $pageSize = isset($get['pageSize']) && !empty($get['pageSize']) ? $get['pageSize'] : Yii::$app->params['pageSize'];
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        $return = $model->getList($select, $where, $page, $pageSize, $order, $with);
+        return $return;
+    }
+
+    //查询指定条数 ssh 2019.11.30
+    public static function getLimitList($select, $where, $limit = 10, $order = '', $with = '')
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        $return = $model->getLimitList($select, $where, $limit, $order, $with);
+        return $return;
+    }
+
+    public static function add($data, $returnObject = false)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->add($data, $returnObject);
+    }
+
+    /**
+     * 批量添加
+     */
+    public static function batchAdd($data)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        $model->batchAdd($data);
+    }
+
+    /**
+     * 根据主键ID删除一条记录
+     */
+    public static function deleteById($id)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->deleteById($id);
+    }
+
+    /**
+     *根据条件删除一条或多条记录
+     */
+    public static function deleteByCondition($condition)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        $count = $model->deleteByCondition($condition);
+        return $count;
+    }
+
+    //根据id批量删 ssh 2019.12.7
+    public static function deleteByIds($ids)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->deleteByIds($ids);
+    }
+
+    /**
+     * 根据主键ID更新一条记录
+     */
+    public static function updateById($id, $data)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->updateById($id, $data);
+    }
+
+    //根据多个主键id更新 ssh 2019.9.3
+    public static function updateByIds($ids, $data)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->updateByIds($ids, $data);
+    }
+
+    /**
+     * 根据条件更新一条或多条记录
+     */
+    public static function updateByCondition($condition, $data)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        $count = $model->updateByCondition($condition, $data);
+        return $count;
+    }
+
+    /**
+     * 根据主键ID查出一条记录
+     */
+    public static function getById($id, $returnObject = false)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->getById($id, $returnObject);
+    }
+
+    //随机取一个 ssh 2020.2.10
+    public static function getOne($returnObject = false, $order = false)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->getOne($returnObject, $order);
+    }
+
+    /**
+     *根据条件查出一条记录
+     */
+    public static function getByCondition($condition, $returnObject = false, $order = false)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->getByCondition($condition, $returnObject, $order);
+    }
+
+    //是否存在  ssh 2019.8.30
+    public static function exists($condition)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->exists($condition);
+    }
+
+    /**
+     *根据条件查出多条记录
+     */
+    public static function getAllByCondition($condition, $order = null, $field, $indexBy = null, $returnObject = false)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->getAllByCondition($condition, $order, $field, $indexBy, $returnObject);
+    }
+
+    /**
+     * 根据多个主键ID查询多条记录
+     */
+    public static function getByIds($ids, $order = null, $indexBy = null)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->getByIds($ids, $order, $indexBy);
+    }
+
+    /**
+     *根据条件查出数量
+     */
+    public static function getCount($condition)
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->getCount($condition);
+    }
+
+    //计数器+1-1 shizq 2019-12-05
+    public static function counters($counters, $condition, $params = [])
+    {
+        $model = Yii::createObject(['class' => static::$baseFile]);
+        return $model->counters($counters, $condition, $params);
+    }
+
 }

+ 7 - 2
common/base/models/Base.php

@@ -230,7 +230,7 @@ class Base extends ActiveRecord
     /**
      *根据条件查出多条记录
      */
-    public function getAllByCondition($condition, $order = null, $field, $indexBy = null)
+    public function getAllByCondition($condition, $order = null, $field, $indexBy = null, $returnObject = false)
     {
         $query = $this->conditionQuery($condition)->select($field);
         if (isset($indexBy)) {
@@ -239,7 +239,12 @@ class Base extends ActiveRecord
         if (isset($order)) {
             $query->orderBy($order);
         }
-        return $query->asArray()->all();
+
+        if ($returnObject == false) {
+            return $query->asArray()->all();
+        } else {
+            return $query->all();
+        }
     }
 
     /**

+ 157 - 157
common/base/services/BaseService.php

@@ -4,161 +4,161 @@ namespace common\base\services;
 
 class BaseService
 {
-	public static $baseFile;
-	public static $requireParams;
-	
-	//查询全部 ssh 2019.11.27
-	public static function getAllList($select, $where, $order = '', $with = '')
-	{
-		$class = static::$baseFile;
-		$result = $class::getAllList($select, $where, $order, $with);
-		return $result;
-	}
-	
-	//分页查询 ssh 2019.9.21
-	public static function getList($select, $where, $order = '', $with = '')
-	{
-		$class = static::$baseFile;
-		return $class::getList($select, $where, $order, $with);
-	}
-	
-	//查询指定条数 ssh 2019.11.30
-	public static function getLimitList($select, $where, $limit, $order = '', $with = '')
-	{
-		$class = static::$baseFile;
-		return $class::getLimitList($select, $where, $limit, $order, $with);
-	}
-	
-	public static function add($data, $returnObject = false)
-	{
-		$class = static::$baseFile;
-		return $class::add($data, $returnObject);
-	}
-	
-	/**
-	 * 批量添加
-	 */
-	public static function batchAdd($data)
-	{
-		$class = static::$baseFile;
-		return $class::batchAdd($data);
-	}
-	
-	/**
-	 * 根据主键ID删除一条记录
-	 */
-	public static function deleteById($id)
-	{
-		$class = static::$baseFile;
-		return $class::deleteById($id);
-	}
-	
-	/**
-	 *根据条件删除一条或多条记录
-	 */
-	public static function deleteByCondition($condition)
-	{
-		$class = static::$baseFile;
-		$count = $class::deleteByCondition($condition);
-		return $count;
-	}
-	
-	//根据id批量删除 ssh 2019.12.7
-	public static function deleteByIds($ids)
-	{
-		$class = static::$baseFile;
-		return $class::deleteByIds($ids);
-	}
-	
-	/**
-	 * 根据主键ID更新一条记录
-	 */
-	public static function updateById($id, $data)
-	{
-		$class = static::$baseFile;
-		return $class::updateById($id, $data);
-	}
-	
-	//根据多个主键id更新 ssh 2019.9.3
-	public static function updateByIds($ids, $data)
-	{
-		$class = static::$baseFile;
-		return $class::updateByIds($ids, $data);
-	}
-	
-	/**
-	 * 根据条件更新一条或多条记录
-	 */
-	public static function updateByCondition($condition, $data)
-	{
-		$class = static::$baseFile;
-		return $class::updateByCondition($condition, $data);
-	}
-	
-	/**
-	 * 根据主键ID查出一条记录
-	 */
-	public static function getById($id, $returnObject = false)
-	{
-		$class = static::$baseFile;
-		return $class::getById($id, $returnObject);
-	}
-	
-	/**
-	 *根据条件查出一条记录
-	 */
-	public static function getByCondition($condition, $returnObject = false, $order = false)
-	{
-		$class = static::$baseFile;
-		return $class::getByCondition($condition, $returnObject, $order);
-	}
-	
-	//是否存在 ssh 2019.8.30
-	public static function exists($condition)
-	{
-		$class = static::$baseFile;
-		return $class::exists($condition);
-	}
-	
-	/**
-	 *根据条件查出多条记录
-	 */
-	public static function getAllByCondition($condition, $order = null, $field, $indexBy = null)
-	{
-		$class = static::$baseFile;
-		return $class::getAllByCondition($condition, $order, $field, $indexBy);
-	}
-	
-	/**
-	 * 根据多个主键ID查询多条记录
-	 */
-	public static function getByIds($ids, $order = null, $indexBy = null)
-	{
-		$class = static::$baseFile;
-		return $class::getByIds($ids, $order, $indexBy);
-	}
-	
-	/**
-	 *根据条件查出数量
-	 */
-	public static function getCount($condition)
-	{
-		$class = static::$baseFile;
-		return $class::getCount($condition);
-	}
-	
-	//计数器+1-1 shizq 2019-12-05
-	public static function counters($counters, $condition, $params = [])
-	{
-		$class = static::$baseFile;
-		return $class::counters($counters, $condition, $params);
-	}
-	
-	//随机取一个 ssh 2020.3.12
-	public static function getOne($returnObject = false, $order = false)
-	{
-		$class = static::$baseFile;
-		return $class::getOne($returnObject = false, $order = false);
-	}
-	
+    public static $baseFile;
+    public static $requireParams;
+
+    //查询全部 ssh 2019.11.27
+    public static function getAllList($select, $where, $order = '', $with = '')
+    {
+        $class = static::$baseFile;
+        $result = $class::getAllList($select, $where, $order, $with);
+        return $result;
+    }
+
+    //分页查询 ssh 2019.9.21
+    public static function getList($select, $where, $order = '', $with = '')
+    {
+        $class = static::$baseFile;
+        return $class::getList($select, $where, $order, $with);
+    }
+
+    //查询指定条数 ssh 2019.11.30
+    public static function getLimitList($select, $where, $limit, $order = '', $with = '')
+    {
+        $class = static::$baseFile;
+        return $class::getLimitList($select, $where, $limit, $order, $with);
+    }
+
+    public static function add($data, $returnObject = false)
+    {
+        $class = static::$baseFile;
+        return $class::add($data, $returnObject);
+    }
+
+    /**
+     * 批量添加
+     */
+    public static function batchAdd($data)
+    {
+        $class = static::$baseFile;
+        return $class::batchAdd($data);
+    }
+
+    /**
+     * 根据主键ID删除一条记录
+     */
+    public static function deleteById($id)
+    {
+        $class = static::$baseFile;
+        return $class::deleteById($id);
+    }
+
+    /**
+     *根据条件删除一条或多条记录
+     */
+    public static function deleteByCondition($condition)
+    {
+        $class = static::$baseFile;
+        $count = $class::deleteByCondition($condition);
+        return $count;
+    }
+
+    //根据id批量删除 ssh 2019.12.7
+    public static function deleteByIds($ids)
+    {
+        $class = static::$baseFile;
+        return $class::deleteByIds($ids);
+    }
+
+    /**
+     * 根据主键ID更新一条记录
+     */
+    public static function updateById($id, $data)
+    {
+        $class = static::$baseFile;
+        return $class::updateById($id, $data);
+    }
+
+    //根据多个主键id更新 ssh 2019.9.3
+    public static function updateByIds($ids, $data)
+    {
+        $class = static::$baseFile;
+        return $class::updateByIds($ids, $data);
+    }
+
+    /**
+     * 根据条件更新一条或多条记录
+     */
+    public static function updateByCondition($condition, $data)
+    {
+        $class = static::$baseFile;
+        return $class::updateByCondition($condition, $data);
+    }
+
+    /**
+     * 根据主键ID查出一条记录
+     */
+    public static function getById($id, $returnObject = false)
+    {
+        $class = static::$baseFile;
+        return $class::getById($id, $returnObject);
+    }
+
+    /**
+     *根据条件查出一条记录
+     */
+    public static function getByCondition($condition, $returnObject = false, $order = false)
+    {
+        $class = static::$baseFile;
+        return $class::getByCondition($condition, $returnObject, $order);
+    }
+
+    //是否存在 ssh 2019.8.30
+    public static function exists($condition)
+    {
+        $class = static::$baseFile;
+        return $class::exists($condition);
+    }
+
+    /**
+     *根据条件查出多条记录
+     */
+    public static function getAllByCondition($condition, $order = null, $field, $indexBy = null, $returnObject = false)
+    {
+        $class = static::$baseFile;
+        return $class::getAllByCondition($condition, $order, $field, $indexBy, $returnObject);
+    }
+
+    /**
+     * 根据多个主键ID查询多条记录
+     */
+    public static function getByIds($ids, $order = null, $indexBy = null)
+    {
+        $class = static::$baseFile;
+        return $class::getByIds($ids, $order, $indexBy);
+    }
+
+    /**
+     *根据条件查出数量
+     */
+    public static function getCount($condition)
+    {
+        $class = static::$baseFile;
+        return $class::getCount($condition);
+    }
+
+    //计数器+1-1 shizq 2019-12-05
+    public static function counters($counters, $condition, $params = [])
+    {
+        $class = static::$baseFile;
+        return $class::counters($counters, $condition, $params);
+    }
+
+    //随机取一个 ssh 2020.3.12
+    public static function getOne($returnObject = false, $order = false)
+    {
+        $class = static::$baseFile;
+        return $class::getOne($returnObject = false, $order = false);
+    }
+
 }

+ 3 - 0
common/components/dict.php

@@ -89,6 +89,8 @@ class dict
             'xhPurchase' => ['id' => 11, 'name' => 'xhPurchase'],
             //培训报名
             'pxApply' => ['id' => 12, 'name' => 'pxApply'],
+            //花店采购结算
+            'hdPurchaseClear' => ['id' => 20, 'name' => 'hdPurchaseClear'],
         ],
         "capitalTypeList" => [//流水类型的对应链接,后台收支明细查看时跳转的链接
             0 => ['link' => '/capital/order-detail', 'name' => '网店', 'orderLink' => '/order/detail', 'id' => 0,],
@@ -102,6 +104,7 @@ class dict
             10 => ['link' => '/capital/order-detail', 'name' => '订单', 'orderLink' => '', 'id' => 10,],
             11 => ['link' => '/capital/purchase-detail', 'name' => '订单', 'orderLink' => '', 'id' => 11,],
             12 => ['link' => '/capital/purchase-detail', 'name' => '培训报名', 'orderLink' => '', 'id' => 12,],
+            20 => ['link' => '', 'name' => '采购结算', 'orderLink' => '', 'id' => 20,],
         ],
 
 

+ 5 - 2
sql.sql

@@ -2267,7 +2267,8 @@ CHANGE COLUMN `num` `itemNum`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '大
 MODIFY COLUMN `price`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '单价' AFTER `ratio`,
 ADD COLUMN `itemId`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '花材ID' AFTER `productId`,
 ADD COLUMN `itemInfo`  text NOT NULL COMMENT '花材信息json' AFTER `itemNum`;
-=======
+
+======= shish 20210428
 ALTER TABLE xhGhsOrder ADD cgId INT NOT NULL DEFAULT 0 COMMENT '采购单id' AFTER `id`;
 ALTER TABLE `xhGhsOrder` CHANGE `cgId` `hdOrderId` INT NOT NULL DEFAULT 0 COMMENT '花店订单id';
 ALTER TABLE `xhPurchase` ADD ghsOrderId INT NOT NULL DEFAULT 0 COMMENT '供货商订单id' AFTER `orderSn`;
@@ -2276,4 +2277,6 @@ ALTER TABLE `xhGhs` ADD customId INT NOT NULL DEFAULT 0 COMMENT 'a是b的供货
 ALTER TABLE `xhGhsCustom` ADD ghsId INT NOT NULL DEFAULT 0 COMMENT 'a是b的客户,则b是a的供货商,即供货商id' AFTER `id`;
 ALTER TABLE `xhGhs` DROP COLUMN `customId`;
 ALTER TABLE `xhGhsCustom` DROP COLUMN `ghsId`;
-
+ALTER TABLE xhPurchaseClear ADD `status` TINYINT NOT NULL DEFAULT 1 COMMENT '状态 1待付款 2已付款 3已取消,已失效' AFTER `changePrice`;
+ALTER TABLE xhPurchaseClear ADD shopId INT NOT NULL DEFAULT 0 COMMENT '门店id' AFTER `merchantId`;
+ALTER TABLE xhPurchaseClear CHANGE `merchantId` `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id'