|
|
@@ -1248,4 +1248,34 @@ class CustomController extends BaseController
|
|
|
util::complete('修改成功');
|
|
|
}
|
|
|
|
|
|
+ public function actionRefreshBuyamount()
|
|
|
+ {
|
|
|
+ $customId = intval(Yii::$app->request->get('customId'));
|
|
|
+ if ($customId <= 0) {
|
|
|
+ util::fail('客户ID参数错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $custom = CustomClass::getById($customId, true);
|
|
|
+ CustomClass::valid($custom, $this->shopId);
|
|
|
+ $ghsId = $custom->ghsId ?? 0;
|
|
|
+ $ghs = GhsClass::getById($ghsId, true);
|
|
|
+ if (empty($ghs)) {
|
|
|
+ util::fail('客户信息有问题');
|
|
|
+ }
|
|
|
+ $orderList = OrderClass::getAllByCondition(['customId' => $customId], null, 'id, actPrice');
|
|
|
+ $buyAmount = 0;
|
|
|
+ if (!empty($orderList)) {
|
|
|
+ foreach ($orderList as $order) {
|
|
|
+ $buyAmount = bcadd($buyAmount, $order['actPrice'], 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $custom->buyAmount = $buyAmount;
|
|
|
+ $custom->save();
|
|
|
+
|
|
|
+ $ghs->expendAmount = $buyAmount;
|
|
|
+ $ghs->save();
|
|
|
+
|
|
|
+ util::success(['buyAmount' => $buyAmount]);
|
|
|
+ }
|
|
|
}
|