| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace addons\Store\common\models;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_store_commission_check".
- *
- * @property int $id
- * @property int $mall_id 商城id
- * @property int $store_id 门店id
- * @property int $store_commission_id 提成明细id
- * @property string $order_no 订单编号
- * @property string $voucher_img 凭证图片
- * @property int $check_status 审核状态[0:待审核;1:已同意;2:已驳回]
- * @property int $created_at
- * @property int $updated_at
- * @property int|null $status 状态[-1:删除;0:禁用;1启用]
- */
- class StoreCommissionCheck extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_store_commission_check}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'store_id', 'store_commission_id', 'check_status', 'created_at', 'updated_at', 'status'], 'integer'],
- [['order_no'], 'string', 'max' => 100],
- [['voucher_img'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城id',
- 'store_id' => '门店id',
- 'store_commission_id' => '提成明细id',
- 'order_no' => '订单编号',
- 'voucher_img' => '凭证图片',
- 'check_status' => '审核状态[0:待审核;1:已同意;2:已驳回]',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- ];
- }
- public static function setData(array $params)
- {
- try {
- $model = new self();
- $model->loadDefaultValues();
- if (!$model->load($params, '') || !$model->save()) {
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage() . $e->getLine() . $e->getFile();
- return false;
- }
- }
- public static function check($ids, $mall_id, $chek_status,$store_id,$order_no)
- {
- $t = Yii::$app->db->beginTransaction();
- try {
- if ($chek_status == 1) {
- //通过
- Store::settlementStoreCommission('', $store_id, $order_no);//结算货款
- }
- $res = self::updateAll(['check_status' => $chek_status], ['id' => $ids, 'mall_id' => $mall_id]);
- if ($res == false) throw new \Exception(self::getStaticError());
- $t->commit();
- return true;
- } catch (\Exception $e) {
- $t->rollBack();
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|