StoreOrderCartInfo.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/12/26
  6. */
  7. namespace app\models\store;
  8. use crmeb\basic\BaseModel;
  9. use crmeb\traits\ModelTrait;
  10. /**
  11. * TODO 订单记录Model
  12. * Class StoreOrderCartInfo
  13. * @package app\models\store
  14. */
  15. class StoreOrderCartInfo extends BaseModel
  16. {
  17. /**
  18. * 模型名称
  19. * @var string
  20. */
  21. protected $name = 'store_order_cart_info';
  22. use ModelTrait;
  23. public static function getCartInfoAttr($value)
  24. {
  25. return json_decode($value,true)?:[];
  26. }
  27. public static function setCartInfo($oid,array $cartInfo)
  28. {
  29. $group = [];
  30. foreach ($cartInfo as $cart){
  31. $group[] = [
  32. 'oid'=>$oid,
  33. 'cart_id'=>$cart['id'],
  34. 'product_id'=>$cart['productInfo']['id'],
  35. 'cart_info'=>json_encode($cart),
  36. 'unique'=>md5($cart['id'].''.$oid)
  37. ];
  38. }
  39. return self::setAll($group);
  40. }
  41. public static function getProductNameList($oid)
  42. {
  43. $cartInfo = self::where('oid',$oid)->select();
  44. $goodsName = [];
  45. foreach ($cartInfo as $cart){
  46. $suk = isset($cart['cart_info']['productInfo']['attrInfo']) ? '('.$cart['cart_info']['productInfo']['attrInfo']['suk'].')' : '';
  47. $goodsName[] = $cart['cart_info']['productInfo']['store_name'].$suk;
  48. }
  49. return $goodsName;
  50. }
  51. }