ShopGoods.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <?php
  2. namespace common\models;
  3. /**
  4. * This is the model class for table "{{%SHOP_GOODS}}".
  5. *
  6. * @property string $ID
  7. * @property string $GOODS_NAME 商品名称
  8. * @property string $CATE_ID 所属分类ID
  9. * @property string $TYPE 商品来源
  10. * @property string $GIFT_TYPE 商品类型
  11. * @property string $CATEGORY_TYPE 商品分类
  12. * @property string $SELL_TYPE 允许购买方式
  13. * @property int $GOODS_NO 商品编号
  14. * @property string $UNIT 单位
  15. * @property string $COVER 商品封面
  16. * @property int $IMAGES 商品图片
  17. * @property string $CONTENT 商品内容
  18. * @property string $SELL_PRICE 销售价格
  19. * @property string $SELL_PRICE_STANDARD 标准价格
  20. * @property string $MARKET_PRICE 市场价格
  21. * @property int $PRICE_PV 价格PV
  22. * @property string $TAX_RATE 税率
  23. * @property int $POINT 兑换积分
  24. * @property int $STORE_NUMS 库存
  25. * @property int $IS_DEL 是否删除
  26. * @property int $CREATED_AT 创建时间
  27. * @property int $UPDATED_AT 更新时间
  28. * @property int $DELETED_AT 删除时间
  29. * @property int $STATUS 状态
  30. * @property string $SORT 排序
  31. */
  32. class ShopGoods extends \common\components\ActiveRecord
  33. {
  34. const SALE_TYPE = [
  35. 1 => [
  36. 'id' => 1,
  37. 'name' => 'Account Balance', //余额购买
  38. 'label' => 'cash',
  39. ],
  40. // 2 => [
  41. // 'id' => 2,
  42. // 'name' => '复消兑换',
  43. // ],
  44. // 3 => [
  45. // 'id' => 3,
  46. // 'name' => '兑换点数',
  47. // 'label' => 'exchange',
  48. // ],
  49. 4 => [
  50. 'id' => 4,
  51. 'name' => 'Travel Bonus',
  52. 'label' => 'tourism_points',
  53. ],
  54. 5 => [
  55. 'id' => 5,
  56. 'name' => 'Car Fund',
  57. 'label' => 'garage_points',
  58. ],
  59. 6 => [
  60. 'id' => 6,
  61. 'name' => 'Villa Fund',
  62. 'label' => 'villa_points',
  63. ],
  64. 7 => [
  65. 'id' => 7,
  66. 'name' => 'PayStack',
  67. 'label' => 'pay_stack',
  68. ],
  69. ];
  70. const GOODS_TYPE = [
  71. 1 =>[
  72. 'name'=>'国内商品',//国内商品
  73. 'discount'=>'50',
  74. ],
  75. 2 =>[
  76. 'name'=>'进口商品',//进口商品
  77. 'discount'=>'60',
  78. ],
  79. ];
  80. const GIFT_TYPE = [
  81. 1 =>[
  82. 'name'=>'1st Purchase',//报单区
  83. ],
  84. 2 =>[
  85. 'name'=>'Repeat Purchase',//复消区
  86. ],
  87. 3 =>[
  88. 'name'=>'Office Entry area',//工作室报单
  89. ],
  90. 4 =>[
  91. 'name'=>'Office Reselling area',//工作室复消
  92. ],
  93. ];
  94. const STATUS_NAME = [
  95. 1 => 'On sale',//已上架
  96. 0 => 'Sold out',//已下架
  97. ];
  98. const CATEGORY_TYPE = [
  99. [
  100. 'id' => 1,
  101. 'name' => 'Standard Products',//普通商品
  102. 'sell_type' => [
  103. self::SALE_TYPE[1],
  104. // self::SALE_TYPE[3],
  105. self::SALE_TYPE[7],
  106. ]
  107. ],
  108. // [
  109. // 'id' => 4,
  110. // 'name' => 'Travel bonus products',//旅游积分商品
  111. // 'sell_type' => [
  112. // self::SALE_TYPE[4]
  113. // ]
  114. // ],
  115. [
  116. 'id' => 5,
  117. 'name' => 'Car Fund Products',
  118. 'sell_type' => [
  119. self::SALE_TYPE[5]
  120. ]
  121. ],
  122. [
  123. 'id' => 6,
  124. 'name' => 'Villa Fund Products',
  125. 'sell_type' => [
  126. self::SALE_TYPE[6]
  127. ]
  128. ],
  129. ];
  130. /**
  131. * @inheritdoc
  132. */
  133. public static function tableName()
  134. {
  135. return '{{%SHOP_GOODS}}';
  136. }
  137. /**
  138. * @inheritdoc
  139. */
  140. public function rules()
  141. {
  142. return [
  143. [['SELL_DISCOUNT','GOODS_NAME', 'CATE_ID','GIFT_TYPE', 'GOODS_NO', 'SELL_PRICE','MARKET_PRICE','PRICE_PV','STORE_NUMS', 'SELL_TYPE', 'CATEGORY_TYPE', 'SELL_PRICE_STANDARD', 'TAX_RATE'], 'required'],
  144. [['STORE_NUMS'], 'integer'],
  145. [['SELL_PRICE','MARKET_PRICE','PRICE_PV','POINT',/* 'SELL_TYPE',*/ 'CATEGORY_TYPE' ,'SELL_PRICE_STANDARD', 'TAX_RATE'], 'number'],
  146. [['ID','CATE_ID', 'GOODS_NO','GIFT_TYPE'], 'string', 'max' => 32],
  147. [['UNIT'], 'string', 'max' => 16],
  148. [['COVER', 'GOODS_NAME'], 'string', 'max' => 255],
  149. [['IMAGES','CONTENT'], 'string', 'max' => 4000],
  150. [['GOODS_NAME'], 'unique'],
  151. [['ID'], 'unique'],
  152. ];
  153. }
  154. /**
  155. * @inheritdoc
  156. */
  157. public function attributeLabels()
  158. {
  159. return [
  160. 'ID' => 'ID',
  161. 'GOODS_NAME' => '商品名称',
  162. 'CATE_ID' => '所属分类ID',
  163. // 'TYPE' => '商品来源',
  164. 'SELL_DISCOUNT' => '会员折扣',
  165. 'GIFT_TYPE' => '商品类型',
  166. 'CATEGORY_TYPE' => '商品分类',
  167. 'SELL_TYPE' => '出售方式',
  168. 'GOODS_NO' => '商品编号',
  169. 'UNIT' => '商品单位',
  170. 'COVER' => '商品封面',
  171. 'IMAGES' => '商品图片',
  172. 'CONTENT' => '商品内容',
  173. 'SELL_PRICE' => '销售价格',
  174. 'SELL_PRICE_STANDARD' => 'US price($)',
  175. 'MARKET_PRICE' => '市场价格',
  176. 'PRICE_PV' => '价格PV',
  177. 'TAX_RATE' => '税率',
  178. 'TAX_AMOUNT' => '税额',
  179. // 'POINT' => '兑换积分',
  180. 'STORE_NUMS' => '库存',
  181. 'STATUS' => '是否上架',
  182. 'IS_DEL' => '是否删除',
  183. 'CREATED_AT' => '创建时间',
  184. 'UPDATED_AT' => '更新时间',
  185. 'DELETED_AT' => '更新时间',
  186. 'SORT' => '排序',
  187. ];
  188. }
  189. /**
  190. * 判断提现状态
  191. * @param $nowStatus
  192. * @param $toStatus
  193. * @return string
  194. */
  195. public static function chkAuditStatus($nowStatus, $toStatus) {
  196. $statusName = self::STATUS_NAME;
  197. $msg = 'The current product status is【' . $statusName[$nowStatus] . '】,cannot be set to【' . $statusName[$toStatus] . '】';// 当前商品状态为 无法设置为
  198. switch ($toStatus) {
  199. // 下架
  200. case 0:
  201. if ($nowStatus == 1) {
  202. $msg = '';
  203. }
  204. break;
  205. //上架
  206. case 1:
  207. if ($nowStatus == 0) {
  208. $msg = '';
  209. }
  210. break;
  211. default:
  212. }
  213. return $msg;
  214. }
  215. /**
  216. * 支付方式
  217. * @return array
  218. */
  219. public static function payTypes(){
  220. return [
  221. 'cash'=>[
  222. 'name'=>'Ecoin' //余额支付
  223. ],
  224. // 'point'=>[
  225. // 'name'=>'积分支付' //积分支付
  226. // ],
  227. // 'exchange' => [
  228. // 'name' => '积分点数'
  229. // ],
  230. // 'tourism_points'=>[
  231. // 'name'=>'Travel Bonus'
  232. // ],
  233. 'garage_points' => [
  234. 'name' => 'Car Fund'
  235. ],
  236. 'villa_points' => [
  237. 'name' => 'Villa Fund'
  238. ],
  239. 'pay_stack' => [
  240. 'name' => 'PayStack'
  241. ],
  242. ];
  243. }
  244. }