コード例 #1
0
 public function getDetails($orderIds)
 {
     $rs = StoreStoreDetail::find()->joinWith('goods')->where(['in', 'order_id', $orderIds])->all();
     $detail = [];
     foreach ($rs as $model) {
         $detail[$model->order_id][] = ['goods_name' => isset($model->goods->name) ? $model->goods->name : '', 'count' => $model->count, 'remark' => $model->remark, 'order_id' => $model->order_id];
     }
     return $detail;
 }
コード例 #2
0
 public function actionList()
 {
     $rs = StoreStoreDetail::search();
     $data = [];
     foreach ($rs['model'] as $value) {
         $data[] = ['id' => $value->id, 'order_id' => $value->order_id, 'goods_name' => $value->goods->name, 'count' => $value->count, 'datetime' => $value->datetime, 'remake' => $value->remark, 'flag' => $value->flag, 'status' => $value->status];
     }
     echo json_encode(['count' => $rs['count'], 'rows' => $data]);
     Yii::$app->end();
 }
コード例 #3
0
ファイル: StoreInstore.php プロジェクト: jy02511876/wiiphp
 public function getDetail()
 {
     return $this->hasMany(StoreStoreDetail::className(), ['order_id' => 'order_id']);
 }
コード例 #4
0
 public function actionConfirm()
 {
     $id = Yii::$app->request->getBodyParam('id');
     $model = StoreOutstore::findOne($id);
     if ($model === null) {
         $this->ajax_return(false, '找不到该订单');
     }
     if ($model->status == 'succ') {
         $this->ajax_return(true, '该订单已确认出库过了!');
     }
     if ($model->status == 'wait') {
         $trans = Yii::$app->db->beginTransaction();
         try {
             $model->status = 'succ';
             //更新宣传品的库存
             $list = StoreStoreDetail::getListByOrderId($model->order_id);
             $goodsUpdate = true;
             foreach ($list as $value) {
                 $goodsModel = StoreGoods::findOne($value->goods_id);
                 $goodsModel->count = $goodsModel->count - $value->count;
                 if ($goodsModel->count < 0) {
                     $this->ajax_return(true, '"' . $goodsModel->name . '"库存不足!');
                 }
                 if (!$goodsModel->save()) {
                     $goodsUpdate = false;
                 }
                 if ($goodsUpdate == false) {
                     break;
                 }
             }
             if ($model->save() && $goodsUpdate && StoreStoreDetail::updateAll(['status' => 'on'], 'order_id="' . $model->order_id . '"')) {
                 $trans->commit();
             } else {
                 $trans->rollBack();
             }
         } catch (Exception $e) {
             $trans->rollBack();
             $this->ajax_return(false, '数据异常');
         }
     }
     $this->ajax_return(true, '操作成功!');
 }
コード例 #5
0
ファイル: TestController.php プロジェクト: jy02511876/wiiphp
 public function actionIndex()
 {
     StoreStoreDetail::getDetails(['OUT2015042400002']);
 }