public function actionUpdateAuditStatu() { $id = Yii::$app->request->post('pk'); //$name = Yii::$app->request->post('name'); $value = Yii::$app->request->post('value'); $order = Order::findOne($id); if ($order->statu != Order::$_AUDIT_PEND) { $result = ['status' => 'error', 'msg' => '该商品已审核!']; echo json_encode($result); return; } $order->statu = $value; if ($order->save()) { $total_num = Order::find()->where('shop = :shop and commodity = :commodity and statu = :statu', [':shop' => $order->shop, ':commodity' => $order->commodity, ':statu' => Order::$_AUDIT_ACCESS])->count(); $fact_fee = Order::find()->where('shop = :shop and commodity = :commodity and statu = :statu', [':shop' => $order->shop, ':commodity' => $order->commodity, ':statu' => Order::$_AUDIT_ACCESS])->sum('fee'); $total_income = Order::find()->where('shop = :shop and commodity = :commodity and statu = :statu', [':shop' => $order->shop, ':commodity' => $order->commodity, ':statu' => Order::$_AUDIT_ACCESS])->sum('money'); $statistics = Statistics::find()->where('shop = :shop and commodity = :commodity', [':shop' => $order->shop, ':commodity' => $order->commodity])->one(); if (!empty($statistics)) { $statistics->total_num = $total_num; $statistics->fact_fee = $fact_fee; //intval($order->fee); $statistics->total_income = $total_income; //floatval($order->money); $statistics->save(); } } $result = ['status' => 'sucess']; echo json_encode($result); }
} } return $data['credit']; }], ['attribute' => '添加时间', 'value' => function ($data) { return $data['create_time']; }], ['class' => 'yii\\grid\\Column', 'header' => '审核状态', 'content' => function ($data) { $html = CommodityOrder::$Audits[$data['statu']]; if ($data['statu'] == CommodityOrder::$_AUDIT_PEND) { $html = '<a href="#" data-type="select" data-name="statu" data-pk="' . $data['id'] . '" data-value="' . $data['statu'] . '" data-title="审核状态">' . CommodityOrder::$Audits[$data['statu']] . '</a>'; } return $html; }], ['class' => 'yii\\grid\\Column', 'header' => '实收金额', 'content' => function ($data) { if (empty($data['real_income'])) { $data['real_income'] = '0.00'; } $statistics = Statistics::find()->where('coid = :coid', [':coid' => $data['id']])->one(); $style = ''; if (!empty($statistics)) { $total = $statistics->corpus + $statistics->total_fee; if ($data['real_income'] != '0.00' && $data['real_income'] < $total) { $style = 'style="color:red;"'; } } return '<a href="#" ' . $style . ' data-type="text" data-name="real_income" data-pk="' . $data['id'] . '" data-value="' . $data['real_income'] . '" data-title="实收金额">' . $data['real_income'] . '</a>'; }], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'template' => '{allot} {view}', 'buttons' => ['allot' => function ($url, $data, $key) { $icon = '<span class="glyphicon glyphicon-user"></span>'; $html = '<a style="color:#d1d1d1;" title="分配">' . $icon . '</a>'; if ($data['statu'] == CommodityOrder::$_AUDIT_ACCESS) { $html = '<a href="allot?id=' . $data['id'] . '" title="分配">' . $icon . '</a>'; } return $html;
public function actionUpdateRealIncome() { $id = Yii::$app->request->post('pk'); //$name = Yii::$app->request->post('name'); $value = Yii::$app->request->post('value'); $commodityOrder = CommodityOrder::findOne($id); $commodityOrder->real_income = $value; if ($commodityOrder->save()) { $statistics = Statistics::find()->where('coid = :coid', [':coid' => $commodityOrder->id])->one(); $statistics->real_income = $value; $statistics->save(); } $result = ['status' => 'sucess']; echo json_encode($result); }