Ejemplo n.º 1
0
 public function initialize()
 {
     $this->item = new Goods();
     $this->attr = new Attr();
     $this->redis = RedisLib::getRedis($this->di);
 }
Ejemplo n.º 2
0
 public function getGoodsAttrs($goodsId)
 {
     $redis = RedisLib::getRedis($this->di);
     $gAttrs = $redis->get('attr:' . $goodsId);
     if (!$gAttrs) {
         //获取该商品的所有属性id
         $gAttrs = (new \Mall\Mdu\Models\GoodsModel())->getGaCates($goodsId);
         //商品搜索的属性id(包括尺码,颜色)缓存1天
         $redis->setex('attr:' . $goodsId, 86400, $gAttrs);
     }
     return $gAttrs;
 }
Ejemplo n.º 3
0
 /**
  * 创建订单(购物车购买)
  */
 public function addBuyCartOrder($uid, $mobi, $orderSn, $totalFee, $paiedFee, $payoffFee, $memo, $shipFee, $isinv, $invType, $invTitle, $addTime, $addr, $goodsDates, $attrsIds, $goodsIds)
 {
     $this->di['db']->begin();
     //创建订单
     if (!($orderId = $this->order->addOrder($uid, $mobi, $orderSn, $totalFee, $paiedFee, $payoffFee, $memo, $shipFee, $isinv, $invType, $invTitle, $addTime, $addr['pro_id'], $addr['city_id'], $addr['dis_id'], $addr['u_addr_info'], $addr['u_addr_zipcode'], $addr['u_addr_consignee'], $addr['u_addr_mobile'], $addr['u_addr_tel']))) {
         $this->di['db']->rollback();
         return self::ERROR;
     }
     //添加订单商品
     if (!$this->order->addMulOrderGoods($orderId, $goodsDates)) {
         $this->di['db']->rollback();
         return self::ERROR;
     }
     //删除已下单的购物车商品
     if (!(new \Mall\Mdu\Models\CartModel())->mulDelCart($uid, $goodsIds, $attrsIds)) {
         $this->di['db']->rollback();
         return self::ERROR;
     }
     //暂时采用下单即扣库存
     if (!$this->order->decrGoodsNums($goodsIds, $attrsIds, $goodsDates)) {
         $this->di['db']->rollback();
         return self::ERROR;
     }
     $this->di['db']->commit();
     //更新购物车商品总数量
     $this->di['session']->set('n', intval($this->di['session']->get('n')) - count($goodsIds));
     $this->di['session']->set('order_id', $orderId);
     foreach ($goodsIds as $k => $gid) {
         \Mall\Utils\RedisLib::getRedis($this->di)->del('item:' . $goodsIds[$k] . ':' . $attrsIds[$k]);
     }
     return self::SUCCESS;
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     $this->item = $this->initModel('\\Mall\\Mdu\\Models\\GoodsModel');
     $this->tags = $this->initModel('\\Mall\\Mdu\\Models\\TagsModel');
     $this->redis = RedisLib::getRedis($this->di);
 }