StoreDouyinMini.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. /**
  9. * Class StoreAliMini
  10. * @package app\models
  11. * @property integer $id
  12. * @property integer $store_id
  13. * @property string $auth_code
  14. * @property string $auth_token
  15. * @property string $userid
  16. * @property integer $is_cancel
  17. * @property string $auth_app_id
  18. * @property string $refresh_token
  19. * @property string $aes_key
  20. * @property integer $is_merchant
  21. * @property string $license_no
  22. * @property string $license_pic
  23. * @property string $app_name
  24. * @property string $app_english_name
  25. * @property string $app_slogan
  26. * @property string $app_logo
  27. * @property string $app_desc
  28. * @property string $aweme_id
  29. * @property string $service_phone
  30. * @property string $service_email
  31. * @property string $mini_categoryIds
  32. * @property string $license_name
  33. * @property string $license_date
  34. * @property string $category_name
  35. * @property integer $is_long_effective
  36. * @property string $alipay_account
  37. * @property string $legal_personal_name
  38. * @property string $contact_name
  39. * @property string $order_no
  40. * @property string $order_no_ali
  41. * @property integer $order_cancel
  42. * @property integer $category_data
  43. * @property string $batch_no
  44. * @property integer $batch_status
  45. * @property string $store_face_photo
  46. * @property integer $is_get_phone
  47. * @property string $apply_phone_msg
  48. * @property string $apply_phone_fail
  49. * @property string $other_data
  50. * @property integer $is_use
  51. * @property integer $shop_status
  52. * @property integer $bind_food_qr
  53. *
  54. *
  55. *
  56. **/
  57. class StoreDouyinMini extends \yii\db\ActiveRecord
  58. {
  59. /**
  60. * @inheritdoc
  61. */
  62. public static function tableName()
  63. {
  64. return '{{%store_douyin_mini}}';
  65. }
  66. /**
  67. * @inheritdoc
  68. */
  69. public function attributeLabels()
  70. {
  71. return [
  72. 'id' => "ID",
  73. 'store_id' => "商户ID",
  74. 'auth' => "授权",
  75. 'auth_app_id' => "小程序ID",
  76. 'is_cancel' => "是否取消授权",
  77. "is_merchant"=> "是否为商户",
  78. "license_no"=> "营业执照编号",
  79. "license_pic"=> "营业执照",
  80. "app_name"=> "小程序名称",
  81. "app_english_name"=> "小程序英文名称",
  82. "app_slogan"=> "小程序应用简介",
  83. "app_logo"=> "小程序LOGO",
  84. "app_desc"=> "小程序应用描述",
  85. "aweme_id"=> "引导关注抖音号",
  86. "service_phone"=> "客服手机号",
  87. "service_email"=> "客服邮箱",
  88. "mini_categoryIds"=> "分类ID",
  89. "license_name"=> "营业执照名称",
  90. "license_date"=> "有效期",
  91. "category_name"=> "分类名称",
  92. "is_long_effective"=> "是否长期有效",
  93. "legal_personal_name"=> "商家法人名称",
  94. "contact_name"=> "商家联系人名称",
  95. "category_data"=> "分类数据",
  96. "store_face_photo"=> "门头照",
  97. "is_get_phone"=> "获取手机号权限状态",
  98. "apply_phone_msg"=> "申请手机号信息资料",
  99. "apply_phone_fail"=> "申请手机号失败信息",
  100. 'other_data'=> "其他申请资料",
  101. 'is_use' => "是否使用",
  102. 'bind_food_qr' => "是否绑定点餐码"
  103. ];
  104. }
  105. public static function authUpdate($mini_id, $auth) {
  106. $appid = $auth['authorizer_appid'];
  107. if($mini_id){
  108. $mini = self::findOne($mini_id);
  109. }else{
  110. $mini = self::findOne(['auth_app_id' => $appid]);
  111. }
  112. if(!$mini){
  113. $mini = new StoreDouyinMini();
  114. $mini->auth_app_id = $appid;
  115. }
  116. $init = 1;
  117. if((empty($mini->auth) || empty($mini->app_name)) && $auth){
  118. $init = 1;
  119. }
  120. $auth && $mini->auth = json_encode($auth);
  121. $auth['store_id'] && $mini->store_id = $auth['store_id'];
  122. if($mini->save()){
  123. return [
  124. 'code' => 0,
  125. 'data' => $mini,
  126. ];
  127. }else{
  128. \Yii::error(array_shift($mini->getFirstErrors()));
  129. return [
  130. 'code' => 0,
  131. 'data' => $mini,
  132. 'msg' => 'StoreDouyinMini数据保存失败,' . array_shift($mini->getFirstErrors()),
  133. ];
  134. }
  135. }
  136. }