ShopGoods.php 6.6 KB

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