...
|
...
|
@@ -9,4 +9,164 @@ |
|
|
class YHMApi_App_V2_Shopping extends YHMApi_App_V1_Shopping
|
|
|
{
|
|
|
use YHMApi_App_V2_Base;
|
|
|
|
|
|
/**
|
|
|
* 提交订单
|
|
|
*
|
|
|
* @param array $params
|
|
|
* @param string $fields
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function commit(array $params, $fields = '*')
|
|
|
{
|
|
|
if (empty($params['product_sku'])) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '请选择购买商品.');
|
|
|
}
|
|
|
if (empty($params['buyer_uid'])) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '购买者不明确.');
|
|
|
}
|
|
|
if (empty($params['delivery_info_id'])) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '送货信息不能为空.');
|
|
|
}
|
|
|
$goodsInfo = YHMProduct_Models_Goods_Client::getOneByProductSkc($params['product_sku']);
|
|
|
$orderRemark = (empty($params['order_remark']) ? '' : $params['order_remark']);
|
|
|
$productSku = $params['product_sku'];
|
|
|
|
|
|
$buyerUid = $params['buyer_uid'];
|
|
|
$paymentID = empty($params['payment_id']) ? 1 : $params['payment_id'];
|
|
|
$shippingFee = empty($params['shipping_fee']) ? 0 : $params['shipping_fee'];
|
|
|
$deliveryInfoID = $params['delivery_info_id'];
|
|
|
$buyNumber = empty($params['buy_number']) ? 1 : $params['buy_number'];
|
|
|
$orderData = array(
|
|
|
'buyer_uid' => $buyerUid,
|
|
|
'buying_way' => 1,
|
|
|
'shipping_fee' => $shippingFee,
|
|
|
'last_shipping_fee' => $shippingFee,
|
|
|
'payment_id' => $paymentID,
|
|
|
'order_remark' => $orderRemark,
|
|
|
'goods_list' => array(
|
|
|
array(
|
|
|
'product_sku' => $productSku,
|
|
|
'buy_number' => $buyNumber
|
|
|
)
|
|
|
)
|
|
|
);
|
|
|
$deliveryInfo = YHMDelivery_Models_Delivery_Client::getDeliveryById($deliveryInfoID);
|
|
|
if (empty($deliveryInfo)) {
|
|
|
return self::result(YHMConfig_Mobile::NOTICE_CODE, '送货信息不能为空.');
|
|
|
}
|
|
|
|
|
|
$resultData = array();
|
|
|
try {
|
|
|
$ordinary = new YHMCart_Orders_Ordinary($buyerUid);
|
|
|
$_orderData = $ordinary->initOrdersData($orderData);
|
|
|
print_r($_orderData);
|
|
|
exit();
|
|
|
foreach ($_orderData as $orderKey => $lastOrderData) {
|
|
|
$returnOrder = $ordinary->create($lastOrderData);
|
|
|
$resultData['order_data'][] = array(
|
|
|
'order_code' => $returnOrder['order_code'],
|
|
|
'last_order_amount' => $returnOrder['last_order_amount']
|
|
|
);
|
|
|
YHMOrders_Models_Delivery_Client::addDelivery($returnOrder['order_code'], $deliveryInfo['delivery_name'], $deliveryInfo['mobile'], $deliveryInfo['area_code'], $deliveryInfo['address'], $deliveryInfo['zip_code']);
|
|
|
}
|
|
|
} catch (Exception $e) {
|
|
|
return self::result(YHMConfig_Mobile::NOTICE_CODE, $e->getMessage());
|
|
|
}
|
|
|
return self::result(YHMConfig_Mobile::SUCCESS_CODE, '订单成功.', $resultData);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 改价订单确认操作
|
|
|
*
|
|
|
* @param array $params
|
|
|
* @param string $fields
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function confirm(array $params, $fields = '*')
|
|
|
{
|
|
|
return self::result(YHMConfig_Mobile::NOTICE_CODE, '改价订单确认操作废弃');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改价格
|
|
|
*
|
|
|
* @param array $params
|
|
|
* @param string $fields
|
|
|
* @return multitype:Integer String mixed string
|
|
|
*/
|
|
|
public static function change(array $params, $fields = '*')
|
|
|
{
|
|
|
if (empty($params['buyer_uid'])) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '缺少购买者.');
|
|
|
}
|
|
|
if (empty($params['product_skc'])) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '缺少购买商品.');
|
|
|
}
|
|
|
if (empty($params['seller_uid'])) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '缺少售卖者.');
|
|
|
}
|
|
|
if(empty($params['order_code'])) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '缺少订单号.');
|
|
|
}
|
|
|
if (empty($params['agreement_price'])) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '缺少修改后的价格.');
|
|
|
}
|
|
|
if ($params['agreement_price'] < 0) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '修改价格不能小于0');
|
|
|
}
|
|
|
if (!isset($params['agreement_shipping_fee'])) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '缺少修改后的运费价格.');
|
|
|
}
|
|
|
if ($params['agreement_shipping_fee'] < 0) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '修改运费价格不能小于0');
|
|
|
}
|
|
|
//订单信息
|
|
|
$order_info = YHMOrders_Models_Orders_Client::getOrdersInfoByOrderCode($params['order_code']);
|
|
|
if (empty($order_info)) {
|
|
|
return self::result(YHMConfig_Mobile::NOTICE_CODE, '没有这个订单');
|
|
|
}
|
|
|
// 目前一个订单只有一个商品,所以取出一条数据
|
|
|
$order_goods = current(YHMOrders_Models_Orders_Client::getGoodsInfoByOrderCode ( $params['order_code']));
|
|
|
if ($order_goods['product_skc'] != $params['product_skc']) {
|
|
|
return self::result(YHMConfig_Mobile::NOTICE_CODE, '没有这个订单商品.');
|
|
|
}
|
|
|
if ($order_info['seller_uid'] != $params['seller_uid']) {
|
|
|
return self::result(YHMConfig_Mobile::WARING_CODE, '此商品不是这个卖家的.');
|
|
|
}
|
|
|
try {
|
|
|
$package = array(
|
|
|
'buyer_uid' => $params['buyer_uid'],
|
|
|
'store_id' => $order_info['store_id'],
|
|
|
'seller_uid' => $order_info['seller_uid'],
|
|
|
'product_skc' => $order_goods['product_skc'],
|
|
|
'sale_price' => $order_goods['sale_price'],
|
|
|
'agreement_shipping_fee' => $params['agreement_shipping_fee'],
|
|
|
'order_shipping_fee' => $order_info['shipping_fee'],
|
|
|
'order_last_shipping_fee' => $order_info['last_shipping_fee'],
|
|
|
'order_amount' => $order_info['order_amount'],
|
|
|
'agreement_price' => $params['agreement_price'],
|
|
|
'buy_number' => $order_goods['buy_number'],
|
|
|
'goods_type' => YHMConfig_Orderstatus::ORDER_GOODS_TYPE_MAIN,
|
|
|
'order_code' =>$params['order_code'],
|
|
|
);
|
|
|
$agreementKey = YHMUtils_Tools::makeAgreementKey($package);
|
|
|
$package['agreement_key'] = $agreementKey;
|
|
|
$agreementID = YHMOrders_Models_Shopping_Client::addShoppingOrderChangePrice($package);
|
|
|
$status = false;
|
|
|
$agreementData = array (
|
|
|
'agreement_key' => $agreementKey,
|
|
|
'agreement_id' => $agreementID
|
|
|
);
|
|
|
if (! empty ( $agreementID )) {
|
|
|
$status = YHMOrders_Models_Orders_Client::updateOrderPrice ( $params ['order_code'], $params ['agreement_price'], $params ['agreement_shipping_fee'], $params ['agreement_shipping_fee'] );
|
|
|
}
|
|
|
if (empty ( $agreementID ) || ! empty ( $status )) {
|
|
|
return self::result(YHMConfig_Mobile::NOTICE_CODE, '改价失败');
|
|
|
}
|
|
|
} catch(Exception $e) {
|
|
|
return self::result(YHMConfig_Mobile::NOTICE_CODE, $e->getMessage());
|
|
|
}
|
|
|
return self::result(YHMConfig_Mobile::SUCCESS_CODE, '改价成功.', $agreementData);
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|