ShopGoods.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. $msg = \Yii::t('ctx', 'shopSetProductStatusErrorNotice', [
  199. 'nowStatus' => $statusName[$nowStatus],
  200. 'newStatus' => $statusName[$toStatus]
  201. ]);
  202. switch ($toStatus) {
  203. // 下架
  204. case 0:
  205. if ($nowStatus == 1) {
  206. $msg = '';
  207. }
  208. break;
  209. //上架
  210. case 1:
  211. if ($nowStatus == 0) {
  212. $msg = '';
  213. }
  214. break;
  215. default:
  216. }
  217. return $msg;
  218. }
  219. /**
  220. * 支付方式
  221. * @return array
  222. */
  223. public static function payTypes(){
  224. return [
  225. 'cash'=>[
  226. 'name'=> \Yii::t('ctx', 'shopPayTypeCash')//余额支付
  227. ],
  228. // 'point'=>[
  229. // 'name'=>'积分支付' //积分支付
  230. // ],
  231. // 'exchange' => [
  232. // 'name' => '积分点数'
  233. // ],
  234. // 'tourism_points'=>[
  235. // 'name'=>'Travel Bonus'
  236. // ],
  237. 'garage_points' => [
  238. 'name' => \Yii::t('ctx', 'shopPayTypeGaragePoints')
  239. ],
  240. 'villa_points' => [
  241. 'name' => \Yii::t('ctx', 'shopPayTypeVillaFund')
  242. ],
  243. 'pay_stack' => [
  244. 'name' => 'PayStack'
  245. ],
  246. ];
  247. }
  248. // 获取商品类型
  249. public static function getGiftType() {
  250. return [
  251. 1 =>[
  252. 'name'=>\Yii::t('ctx', 'shopList1stPurchase'),//报单区
  253. ],
  254. 2 =>[
  255. 'name'=>\Yii::t('ctx', 'shopListRepeatPurchase'),//复消区
  256. ],
  257. 3 =>[
  258. 'name'=>\Yii::t('ctx', 'shopListEntryArea'),//工作室报单
  259. ],
  260. 4 =>[
  261. 'name'=>\Yii::t('ctx', 'shopListResellingArea'),//工作室复消
  262. ],
  263. ];
  264. }
  265. // 获取分类类型
  266. public static function getCategoryType() {
  267. return [
  268. [
  269. 'id' => 1,
  270. 'name' => \Yii::t('ctx', 'shopListStandardProducts'),//普通商品
  271. 'sell_type' => [
  272. self::SALE_TYPE[1],
  273. // self::SALE_TYPE[3],
  274. self::SALE_TYPE[7],
  275. ]
  276. ],
  277. // [
  278. // 'id' => 4,
  279. // 'name' => 'Travel bonus products',//旅游积分商品
  280. // 'sell_type' => [
  281. // self::SALE_TYPE[4]
  282. // ]
  283. // ],
  284. [
  285. 'id' => 5,
  286. 'name' => \Yii::t('ctx', 'shopListCarFundProducts'),
  287. 'sell_type' => [
  288. self::SALE_TYPE[5]
  289. ]
  290. ],
  291. [
  292. 'id' => 6,
  293. 'name' => \Yii::t('ctx', 'shopListVillaFundProducts'),
  294. 'sell_type' => [
  295. self::SALE_TYPE[6]
  296. ]
  297. ],
  298. ];
  299. }
  300. }