ShopGoods.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 $SELL_TYPE 允许购买方式
  12. * @property int $GOODS_NO 商品编号
  13. * @property string $UNIT 单位
  14. * @property string $COVER 商品封面
  15. * @property int $IMAGES 商品图片
  16. * @property string $CONTENT 商品内容
  17. * @property string $SELL_PRICE 销售价格
  18. * @property string $MARKET_PRICE 市场价格
  19. * @property int $PRICE_PV 价格PV
  20. * @property int $POINT 兑换积分
  21. * @property int $STORE_NUMS 库存
  22. * @property int $IS_DEL 是否删除
  23. * @property int $CREATED_AT 创建时间
  24. * @property int $UPDATED_AT 更新时间
  25. * @property int $DELETED_AT 删除时间
  26. * @property int $STATUS 状态
  27. * @property string $SORT 排序
  28. */
  29. class ShopGoods extends \common\components\ActiveRecord
  30. {
  31. const SALE_TYPE = [
  32. 1 => [
  33. 'name' => '余额购买',
  34. ],
  35. 2 => [
  36. 'name' => '复消兑换',
  37. ],
  38. 3 => [
  39. 'name' => '积分兑换'
  40. ]
  41. ];
  42. const GOODS_TYPE = [
  43. 1 =>[
  44. 'name'=>'国内商品',
  45. 'discount'=>'50',
  46. ],
  47. 2 =>[
  48. 'name'=>'进口商品',
  49. 'discount'=>'60',
  50. ],
  51. ];
  52. const GIFT_TYPE = [
  53. 1 =>[
  54. 'name'=>'报单区',
  55. ],
  56. 2 =>[
  57. 'name'=>'复消区',
  58. ],
  59. 3 =>[
  60. 'name'=>'工作室报单',
  61. ],
  62. 4 =>[
  63. 'name'=>'工作室复消',
  64. ],
  65. ];
  66. const STATUS_NAME = [
  67. 1 => '已上架',
  68. 0 => '已下架',
  69. ];
  70. /**
  71. * @inheritdoc
  72. */
  73. public static function tableName()
  74. {
  75. return '{{%SHOP_GOODS}}';
  76. }
  77. /**
  78. * @inheritdoc
  79. */
  80. public function rules()
  81. {
  82. return [
  83. [['SELL_DISCOUNT','GOODS_NAME', 'CATE_ID','GIFT_TYPE', 'GOODS_NO', 'SELL_PRICE','MARKET_PRICE','PRICE_PV','STORE_NUMS'], 'required'],
  84. [['STORE_NUMS'], 'integer'],
  85. [['SELL_PRICE','MARKET_PRICE','PRICE_PV','POINT'], 'number'],
  86. [['ID','CATE_ID', 'GOODS_NO','SELL_TYPE','GIFT_TYPE'], 'string', 'max' => 32],
  87. [['UNIT'], 'string', 'max' => 16],
  88. [['COVER', 'GOODS_NAME'], 'string', 'max' => 255],
  89. [['IMAGES','CONTENT'], 'string', 'max' => 4000],
  90. [['GOODS_NAME'], 'unique'],
  91. [['ID'], 'unique'],
  92. ];
  93. }
  94. /**
  95. * @inheritdoc
  96. */
  97. public function attributeLabels()
  98. {
  99. return [
  100. 'ID' => 'ID',
  101. 'GOODS_NAME' => '商品名称',
  102. 'CATE_ID' => '所属分类ID',
  103. // 'TYPE' => '商品来源',
  104. 'SELL_DISCOUNT' => '会员折扣',
  105. 'GIFT_TYPE' => '商品类型',
  106. 'SELL_TYPE' => '出售方式',
  107. 'GOODS_NO' => '商品编号',
  108. 'UNIT' => '商品单位',
  109. 'COVER' => '商品封面',
  110. 'IMAGES' => '商品图片',
  111. 'CONTENT' => '商品内容',
  112. 'SELL_PRICE' => '销售价格',
  113. 'MARKET_PRICE' => '市场价格',
  114. 'PRICE_PV' => '价格PV',
  115. 'POINT' => '兑换积分',
  116. 'STORE_NUMS' => '库存',
  117. 'STATUS' => '是否上架',
  118. 'IS_DEL' => '是否删除',
  119. 'CREATED_AT' => '创建时间',
  120. 'UPDATED_AT' => '更新时间',
  121. 'DELETED_AT' => '更新时间',
  122. 'SORT' => '排序',
  123. ];
  124. }
  125. /**
  126. * 判断提现状态
  127. * @param $nowStatus
  128. * @param $toStatus
  129. * @return string
  130. */
  131. public static function chkAuditStatus($nowStatus, $toStatus) {
  132. $statusName = self::STATUS_NAME;
  133. $msg = '当前商品状态为【' . $statusName[$nowStatus] . '】,无法设置为【' . $statusName[$toStatus] . '】';
  134. switch ($toStatus) {
  135. // 下架
  136. case 0:
  137. if ($nowStatus == 1) {
  138. $msg = '';
  139. }
  140. break;
  141. //上架
  142. case 1:
  143. if ($nowStatus == 0) {
  144. $msg = '';
  145. }
  146. break;
  147. default:
  148. }
  149. return $msg;
  150. }
  151. /**
  152. * 支付方式
  153. * @return array
  154. */
  155. public static function payTypes(){
  156. return [
  157. 'cash'=>[
  158. 'name'=>'余额支付'
  159. ],
  160. 'point'=>[
  161. 'name'=>'积分支付'
  162. ],
  163. 'exchange' => [
  164. 'name' => '无业绩兑换券'
  165. ]
  166. ];
  167. }
  168. }