Skip to content

Commit

Permalink
Merge pull request #2 from yincart2/develop
Browse files Browse the repository at this point in the history
0.4.0 pre release
  • Loading branch information
yinhe committed Jul 16, 2015
2 parents 021d540 + b5da4e9 commit 4efe298
Show file tree
Hide file tree
Showing 56 changed files with 1,916 additions and 1,082 deletions.
15 changes: 15 additions & 0 deletions common/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@
'sourceLanguage' => 'en-US',
'basePath' => '@star/member/messages',
],
'payment' => [
'class' => 'yii\i18n\PhpMessageSource',
'sourceLanguage' => 'en-US',
'basePath' => '@star/payment/messages',
],
'shipment' => [
'class' => 'yii\i18n\PhpMessageSource',
'sourceLanguage' => 'en-US',
'basePath' => '@star/shipment/messages',
],
'cart' => [
'class' => 'yii\i18n\PhpMessageSource',
'sourceLanguage' => 'en-US',
'basePath' => '@star/cart/messages',
],
],
],
'urlManager' => [
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"c006/yii2-migration-utility": "dev-master",
"yiisoft/yii2-imagine": " *",
"himiklab/yii2-easy-thumbnail-image-helper": "*",
"dektrium/yii2-rbac": "dev-master"
"dektrium/yii2-rbac": "dev-master",
"paypal/rest-api-sdk-php": "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
Expand Down
52 changes: 50 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions star-home/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
'payment' => [
'class' =>'star\payment\Module',
],
'refund' =>[
'class' =>'star\refund\Module',
]
],
'components' => [
'urlManager'=>[
Expand Down
12 changes: 6 additions & 6 deletions star-modules/cart/controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function actionAdd()

$shoppingCartModel = Yii::createObject(ShoppingCart::className()) ;
if($shoppingCartModel->add($sku_id,$star_id, $qty,$data)) {
return Json::encode(['message' => \Yii::t('app', 'add to cart success')]);
return Json::encode(['status'=>'success','message' => \Yii::t('cart', 'add to cart success')]);
} else {
return Json::encode(['message' => \Yii::t('app', 'add to cart fail')]);
return Json::encode(['status'=>'fail','message' => \Yii::t('cart', 'add to cart fail')]);
}
}

Expand Down Expand Up @@ -77,9 +77,9 @@ public function actionRemove()
$shoppingCartModel = Yii::createObject(ShoppingCart::className());
$sku_id = Yii::$app->request->post('sku_id');
if ($shoppingCartModel->remove($sku_id)) {
echo Json::encode(['message' => 'remove success','redirect' =>'index']);
echo Json::encode(['message' => \Yii::t('cart', 'remove success'),'redirect' =>'index']);
} else {
echo Json::encode(['message' => 'remove fail','redirect' =>'index']);
echo Json::encode(['message' =>\Yii::t('cart', 'remove fail') ,'redirect' =>'index']);
}
}

Expand All @@ -89,9 +89,9 @@ public function actionRemove()
public function actionClearAll(){
$shoppingCartModel = Yii::createObject(ShoppingCart::className());
if ($shoppingCartModel->clearAll()) {
echo Json::encode(['message' => 'remove success','redirect' =>'index']);
echo Json::encode(['message' => \Yii::t('cart', 'remove success'),'redirect' =>'index']);
} else {
echo Json::encode(['message' => 'remove fail','redirect' =>'index']);
echo Json::encode(['message' => \Yii::t('cart', 'remove fail'),'redirect' =>'index']);
}
}
}
25 changes: 25 additions & 0 deletions star-modules/cart/messages/zh/cart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Message translations.
*
* This file is automatically generated by 'yii message' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'add to cart success' => '加入购物车成功',
'add to cart fail' => '加入购物车失败',
'remove success' => '删除成功',
'remove fail' => '删除失败',

];
7 changes: 7 additions & 0 deletions star-modules/cart/models/ShoppingCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ public function getTotal()
return $this->getSubTotal() + $this->getShippingFee();
}

public function getTotalQty(){
$qty = 0;
foreach($this->cartItems as $carItem) {
$qty += $carItem->qty;
}
return $qty;
}
/**
* serial cart
* return array like cart['star_id']['sku_id'] = cartModel
Expand Down
6 changes: 3 additions & 3 deletions star-modules/catalog/controllers/home/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public function actionView($id){
public function actionList(){
$catalog = Yii::$app->request->get('catalog');
$item = Yii::createObject(Item::className());
$items = $item::getItemsByCategory($catalog);
$items = $item::getItemsByCategory($catalog)->andWhere(['is_show'=>1]);
$tree = Yii::createObject(Tree::className());
$categories = $tree::getCategoriesById($catalog);
if($items && $categories) {
$pages = new Pagination(['totalCount' => $items->count(), 'pageSize' => '3']);
$pages = new Pagination(['totalCount' => $items->count(), 'pageSize' => '24']);
$items = $items->offset($pages->offset)->limit($pages->limit)->all();
if ($items) {
return $this->render('list', [
Expand All @@ -53,7 +53,7 @@ public function actionList(){
}
return $this->render('//site/error', [
'name' => 'catalog',
'message' => 'There is no product'
'message' => Yii::t('catalog','There is no product'),
]);
}
}
1 change: 1 addition & 0 deletions star-modules/catalog/messages/zh/catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@
'stock' => '库存数量',
'Image(If update,Please upload first)'=>'图片(若更新,请先上传图片)',
'The requested Item could not be found.'=>'您搜索的商品不存在',
'There is no product'=>'没有商品',
];
1 change: 1 addition & 0 deletions star-modules/catalog/views/core/item/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
$fieldGroups = [];
$fields = [];
$fields[] = $form->field($model, 'title')->textInput(['maxlength' => 255]);
$fields[] = $form->field($model, 'price')->textInput(['maxlength' => 255]);
$currency = Currency::find()->all();
$fields[] = $form->field($model, 'currency')->dropDownList(ArrayHelper::map($currency, 'currency_id', 'name'));
$language = Language::find()->all();
Expand Down
3 changes: 3 additions & 0 deletions star-modules/member/messages/zh-CN/member.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
'My Orders' => '摘要',
'Tags' => '标签',
'Title' => '标题',
'Phone' => '手机号',
'Is Default' => '默认地址',
'Zip Code' => '邮政编码',
];
20 changes: 10 additions & 10 deletions star-modules/member/models/DeliveryAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public function rules()
public function attributeLabels()
{
return [
'delivery_address_id' => Yii::t('app', 'Delivery Address ID'),
'user_id' => Yii::t('app', 'User ID'),
'province' => Yii::t('app', 'Province'),
'city' => Yii::t('app', 'City'),
'district' => Yii::t('app', 'District'),
'address' => Yii::t('app', 'Address'),
'zip_code' => Yii::t('app', 'Zip Code'),
'phone' => Yii::t('app', 'Phone'),
'name' => Yii::t('app', 'Name'),
'is_default' => Yii::t('app', 'Is Default'),
'delivery_address_id' => Yii::t('member', 'Delivery Address ID'),
'user_id' => Yii::t('member', 'User ID'),
'province' => Yii::t('member', 'Province'),
'city' => Yii::t('member', 'City'),
'district' => Yii::t('member', 'District'),
'address' => Yii::t('member', 'Address'),
'zip_code' => Yii::t('member', 'Zip Code'),
'phone' => Yii::t('member', 'Phone'),
'name' => Yii::t('member', 'Name'),
'is_default' => Yii::t('member', 'Is Default'),
];
}

Expand Down
9 changes: 6 additions & 3 deletions star-modules/order/controllers/home/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace star\order\controllers\home;

use cluster\modules\cart\models\ShoppingCart;
use star\cart\models\ShoppingCart;
use star\order\models\Order;
use star\catalog\models\Sku;
use star\payment\models\Payment;
use star\payment\models\paypal\PayPal;
use Yii;
use yii\data\Pagination;
use yii\filters\AccessControl;
Expand Down Expand Up @@ -81,8 +83,9 @@ public function actionOrderSave(){
$orderModel->items = Yii::$app->request->post('items');
if ($orderModel->saveOrder()) {

return $this->redirect(['/payment/home/alipay/index', 'id' => $orderModel->order_id]);
return Json::encode(['message' => \Yii::t('app', 'create order success'), 'redirect' => 'success']);
$redirectUrl = Yii::createObject(Payment::className())->getRedirectUrl(Yii::$app->request->post('payment'),$orderModel->order_id);
// var_dump($redirectUrl);exit;
return $this->redirect($redirectUrl);
} else {
return Json::encode(['message' =>'下单失败', 'redirect' => Url::to(['/order/order/index'])]);
}
Expand Down
5 changes: 3 additions & 2 deletions star-modules/order/messages/zh/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
'Wait Confirm' => '待收货',
'Complete' => '订单完成',
'Wait Refund' => '退货中',
'Refund Failed' => '退货未通过',
'Refund Pass' => '退货通过',
'Refund Failed' => '退货申请未通过',
'Refund Pass' => '退货申请通过',
'Order No' => '订单号',
'Orders' => '订单',
'Order' => '订单',
Expand All @@ -41,5 +41,6 @@
'Picture' => '图片',
'Item Name' => '货物名称',
'Shipment' => '物流',
'Wait Refund Checks' => '申请退货',

];
10 changes: 6 additions & 4 deletions star-modules/order/models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ class Order extends \yii\db\ActiveRecord
const STATUS_WAIT_SHIPMENT = 2;
const STATUS_WAIT_CONFIRM = 3;
const STATUS_COMPLETE = 4;
const STATUS_WAIT_REFUND = 5;
const STATUS_REFUND_FAILED = 6;
const STATUS_REFUND_PASS = 7;
const STATUS_WAIT_REFUND_CHECK = 5;
const STATUS_WAIT_REFUND = 6;
const STATUS_REFUND_FAILED = 7;
const STATUS_REFUND_PASS = 8;

const EVENT_CHANGE_PRICE = 'changeOrderPrice';

Expand All @@ -48,6 +49,7 @@ public function getStatusArray(){
self::STATUS_WAIT_SHIPMENT => Yii::t('order','Wait Shipment'),
self::STATUS_WAIT_CONFIRM => Yii::t('order','Wait Confirm'),
self::STATUS_COMPLETE => Yii::t('order','Complete'),
self::STATUS_WAIT_REFUND_CHECK => Yii::t('order','Wait Refund Checks'),
self::STATUS_WAIT_REFUND => Yii::t('order','Wait Refund'),
self::STATUS_REFUND_FAILED => Yii::t('order','Refund Failed'),
self::STATUS_REFUND_PASS => Yii::t('order','Refund Pass'),
Expand Down Expand Up @@ -179,9 +181,9 @@ public function saveSingleOrder($carItems,$starId){
$transaction=\Yii::$app->db->beginTransaction();
try {
$this->user_id = Yii::$app->user->id;
$this->total_price = $ShoppingCart->getSubTotal(0,$starId);
$this->shipping_fee = $ShoppingCart->getShippingFee();
$this->payment_fee = 0;
$this->total_price = $ShoppingCart->getSubTotal(0,$starId)+$this->shipping_fee+$this->payment_fee;
$this->status = self::STATUS_WAIT_PAYMENT;
$this->changePrice();
if ($this->save()) {
Expand Down
Loading

0 comments on commit 4efe298

Please sign in to comment.