|
@@ -3,9 +3,11 @@
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\admin\model\system\SystemAttachment;
|
|
|
+use app\models\store\StoreCart;
|
|
|
use app\models\store\StoreCategory;
|
|
|
use app\models\store\StoreCouponIssue;
|
|
|
use app\models\store\StoreExchange;
|
|
|
+use app\models\store\StoreExchangeOrder;
|
|
|
use app\models\store\StoreOrder;
|
|
|
use app\models\store\StoreProduct;
|
|
|
use app\models\store\StoreService;
|
|
@@ -36,7 +38,34 @@ class PublicController
|
|
|
|
|
|
public function test()
|
|
|
{
|
|
|
- UserRecharge::sendRechargeAward(UserRecharge::get(48));
|
|
|
+ $uid = 168;
|
|
|
+ $product_id = 12;
|
|
|
+ $exchange_id = 3;
|
|
|
+ $num = 32;
|
|
|
+ $uni = '23f2860a';
|
|
|
+ $res = StoreCart::setCart($uid, $product_id, $num, $uni, 'product', 1, 0, 0, 0, 0, $exchange_id);
|
|
|
+ if ($res) {
|
|
|
+ $cartId = $res->id;
|
|
|
+ $cartGroup = StoreCart::getUserProductCartList($uid, [$cartId], 1);
|
|
|
+ if (count($cartGroup['invalid'])) return app('json')->fail($cartGroup['invalid'][0]['productInfo']['store_name'] . '已失效!');
|
|
|
+ if (!$cartGroup['valid']) return app('json')->fail('请提交购买的商品');
|
|
|
+ $cartInfo = $cartGroup['valid'];
|
|
|
+ $priceGroup = StoreOrder::getOrderPriceGroup($cartInfo, 0);
|
|
|
+ $other = [
|
|
|
+ 'offlinePostage' => sys_config('offline_postage'),
|
|
|
+ 'integralRatio' => sys_config('integral_ratio'),
|
|
|
+ ];
|
|
|
+ $orderKey = StoreOrder::cacheOrderInfo($uid, $cartInfo, $priceGroup, $other);
|
|
|
+ if (!$orderKey) return app('json')->fail('生成订单错误!');
|
|
|
+ if (StoreOrder::be(['order_id|unique' => $orderKey, 'uid' => $uid, 'is_del' => 0]))
|
|
|
+ return app('json')->fail('订单已生成');
|
|
|
+ $order = StoreOrder::cacheKeyCreateOrder($uid, $orderKey, 0, 'offline', false, 0, '系统后台订单', 0, 0, 0, 0, 0, $exchange_id, false, 1, 1, '', '', 0, 0, 1);
|
|
|
+
|
|
|
+ if ($order === false) return app('json')->fail(StoreOrder::getErrorInfo('订单生成失败'));
|
|
|
+ else return app('json')->success('订单已生成');
|
|
|
+ } else {
|
|
|
+ return app('json')->fail('加入购物车失败');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|