Authored by whb

添加订单相关代码

... ... @@ -79,6 +79,8 @@ class YHMApi_App_V2_Search extends YHMApi_App_V1_Search {
{
return self::result(YHMConfig_Mobile::NOTICE_CODE, $ex->getMessage());
}
$bannerType = $bannerVal = 0;
$banner = array();
if(!empty($params['category']))
{
$bannerType = YHMSupport_Models_Banner_Client::BANNER_TYPE_CATEGORY;
... ... @@ -93,12 +95,15 @@ class YHMApi_App_V2_Search extends YHMApi_App_V1_Search {
$bannerType = YHMSupport_Models_Banner_Client::BANNER_TYPE_GOODER_SELLER;
}
}
$banner = YHMSupport_Models_Banner_Client::getBannerByType($bannerType, $bannerVal);
if(!empty($banner))
if(!empty($bannerType) && !empty($bannerVal))
{
$result['banner']['banner_describe'] = $banner['banner_describe'];
$result['banner']['banner_url'] = $banner['banner_url'];
$result['banner']['banner_pic'] = YHMUpload_Images::template($banner['banner_pic'], 'yhfair');
$banner = YHMSupport_Models_Banner_Client::getBannerByType($bannerType, $bannerVal);
if(!empty($banner))
{
$result['banner']['banner_describe'] = $banner['banner_describe'];
$result['banner']['banner_url'] = $banner['banner_url'];
$result['banner']['banner_pic'] = YHMUpload_Images::template($banner['banner_pic'], 'yhfair');
}
}
$result['search_list'] = $resultList;
return self::result(YHMConfig_Mobile::SUCCESS_CODE, '搜索列表', $result);
... ...
... ... @@ -11,19 +11,24 @@ class YHMCart_Hook_Calculate_Amount extends YHMCart_Hook_Abstract
static function run(YHMCart_Hook_Orders $package)
{
$lastOrderAmount = $package->getOrderData('last_order_amount');
$last_shipping_fee=$package->getOrderData('last_shipping_fee');
$goods_list=$package->getOrderData('goods_list');
$last_shipping_fee = $package->getOrderData('last_shipping_fee');
$goods_list = $package->getOrderData('goods_list');
if (empty($lastOrderAmount)) {
return;
}
$tmp_amount=0;
$tmp_amount = 0;
foreach($goods_list as $k =>$val)
{
$tmp_amount+=empty($val['last_price'])?0:$val['last_price']*$val['buy_number'];
$tmp_amount += empty($val['last_price']) ? 0: (int)$val['last_price'] * (int)$val['buy_number'];
}
if($tmp_amount+$last_shipping_fee>$lastOrderAmount) //TODO,有待确定
if($tmp_amount != $lastOrderAmount)
{
throw new Exception('实际付款金额小于订单金额、运费的和');
throw new Exception('计算费用不一致');
}
else
{
//运费添加到最终价格
$lastOrderAmount += $last_shipping_fee;
}
$package->setOrderData('last_order_amount', $lastOrderAmount);
}
... ...
... ... @@ -20,17 +20,16 @@ class YHMCart_Hook_Orders_OrdersGoodInfoBase extends YHMCart_Hook_Abstract
* 订单镜像
* @param array $package
*/
static function setGoodsInfo(array $orderData)
{
foreach ($orderData['goods_list'] as $k=>$v){
foreach ($orderData['goods_list'] as $k=>$v)
{
$goods_info=YHMCart_Hook_Orders::getOrderProduct($v['product_sku'],$v['product_skc']);
$v['order_code']=$orderData['order_code'];
$goodsList= array_merge( $goods_info,$v);
YHMOrders_Models_Shopping_Client::setBuyGoodsInfo($goodsList);
}
$goodsList = array_merge( $goods_info,$v);
YHMOrders_Models_Shopping_Client::setBuyGoodsInfo($goodsList);
}
}
... ...
... ... @@ -17,9 +17,10 @@ class YHMCart_Orders_Ordinary extends YHMCart_Orders_Abstract
{
$hookOrders = new YHMCart_Hook_Orders();
$hookOrders->setOrder($orderData);
#################### 创建初始化 ####################
$this->createPreDispatch($hookOrders);
#################### 创建本地订单 ####################
YHMOrders_Models_Shopping_Client::create($hookOrders->getOrder());
#################### 创建成功后 ####################
... ...
... ... @@ -19,7 +19,7 @@ class Shopping
const SELECT_BUY_GOODS_NUMBER = 'SELECT sum(buy_number) as number FROM `orders_goods` as og left join `orders` as o on o.order_code =og.order_code WHERE og.product_sku=:product_sku and o.order_status < :order_status';
const INSERT_ORDERS_GOODS_INFO = 'insert into `orders_goods_info` (`order_code`,`product_skc`,`product_sku`,`buy_number`,`goods_type`,`quality_level`,`sale_price`,`last_price`,`store_id`,`color_id`,`brand_id`,`goods_images`,`color_name`,`goods_name`,`size_name`,`max_category_id`,`middle_category_id`,`small_category_id`,`gender`) values (:order_code,:product_skc,:product_sku,:buy_number,:goods_type,:quality_level,:sale_price,:last_price,:store_id,:color_id,:brand_id,:goods_images,:color_name,:goods_name,:size_name,:max_category_id,:middle_category_id,:small_category_id,:gender)';
const INSERT_ORDERS_GOODS_INFO = 'insert into `orders_goods_info` (`order_code`,`product_skc`,`product_sku`,`buy_number`,`goods_type`,`quality_level`,`sale_price`,`last_price`,`store_id`,`color_id`,`brand_id`,`goods_images`,`color_name`,`goods_name`,`size_name`,`max_category_id`,`middle_category_id`,`small_category_id`,`gender`,`shipping_fee`) values (:order_code,:product_skc,:product_sku,:buy_number,:goods_type,:quality_level,:sale_price,:last_price,:store_id,:color_id,:brand_id,:goods_images,:color_name,:goods_name,:size_name,:max_category_id,:middle_category_id,:small_category_id,:gender,:shipping_fee)';
}
\ No newline at end of file
... ...
... ... @@ -2,4 +2,7 @@
ALTER TABLE `yhm_orders`.`orders` ADD INDEX `idx_order_status` (`order_status`);
ALTER TABLE `orders_goods`
MODIFY COLUMN `product_sku` int(11) UNSIGNED NOT NULL COMMENT '商品sku' AFTER `product_skc`,
\ No newline at end of file
MODIFY COLUMN `product_sku` int(11) UNSIGNED NOT NULL COMMENT '商品sku' AFTER `product_skc`;
ALTER TABLE `yhm_orders`.`orders` CHANGE `last_order_amount` `last_order_amount` DECIMAL(10,2) UNSIGNED NULL COMMENT '订单成交价: 订单成交价 = 订单原价 + 最终运费';
ALTER TABLE `yhm_orders`.`orders_goods_info` ADD COLUMN `shipping_fee` DECIMAL(10,2) NULL COMMENT '订单运费' AFTER `last_price`;
\ No newline at end of file
... ...