StoreCommissionCheck.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace addons\Store\common\models;
  3. use common\models\base\BaseActiveRecord;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_addons_store_commission_check".
  7. *
  8. * @property int $id
  9. * @property int $mall_id 商城id
  10. * @property int $store_id 门店id
  11. * @property int $store_commission_id 提成明细id
  12. * @property string $order_no 订单编号
  13. * @property string $voucher_img 凭证图片
  14. * @property int $check_status 审核状态[0:待审核;1:已同意;2:已驳回]
  15. * @property int $created_at
  16. * @property int $updated_at
  17. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  18. */
  19. class StoreCommissionCheck extends BaseActiveRecord
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public static function tableName()
  25. {
  26. return '{{%addons_store_commission_check}}';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['mall_id', 'store_id', 'store_commission_id', 'check_status', 'created_at', 'updated_at', 'status'], 'integer'],
  35. [['order_no'], 'string', 'max' => 100],
  36. [['voucher_img'], 'string', 'max' => 255],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'mall_id' => '商城id',
  47. 'store_id' => '门店id',
  48. 'store_commission_id' => '提成明细id',
  49. 'order_no' => '订单编号',
  50. 'voucher_img' => '凭证图片',
  51. 'check_status' => '审核状态[0:待审核;1:已同意;2:已驳回]',
  52. 'created_at' => 'Created At',
  53. 'updated_at' => 'Updated At',
  54. 'status' => '状态[-1:删除;0:禁用;1启用]',
  55. ];
  56. }
  57. public static function setData(array $params)
  58. {
  59. try {
  60. $model = new self();
  61. $model->loadDefaultValues();
  62. if (!$model->load($params, '') || !$model->save()) {
  63. throw new \Exception($model->getErrorMessage());
  64. }
  65. return $model;
  66. } catch (\Exception $e) {
  67. self::$static_error = $e->getMessage() . $e->getLine() . $e->getFile();
  68. return false;
  69. }
  70. }
  71. public static function check($ids, $mall_id, $chek_status,$store_id,$order_no)
  72. {
  73. $t = Yii::$app->db->beginTransaction();
  74. try {
  75. if ($chek_status == 1) {
  76. //通过
  77. Store::settlementStoreCommission('', $store_id, $order_no);//结算货款
  78. }
  79. $res = self::updateAll(['check_status' => $chek_status], ['id' => $ids, 'mall_id' => $mall_id]);
  80. if ($res == false) throw new \Exception(self::getStaticError());
  81. $t->commit();
  82. return true;
  83. } catch (\Exception $e) {
  84. $t->rollBack();
  85. self::$static_error = $e->getMessage();
  86. return false;
  87. }
  88. }
  89. }