Sfoglia il codice sorgente

new user ,order ....add depart

abiao 5 anni fa
parent
commit
a19cde67c1

+ 12 - 4
go/gopath/src/fohow.com/apps/controllers/order_controller/order_controller.go

@@ -52,6 +52,10 @@ func (self *OrderController) Create() {
 	//if user.IsBlackUser == 1 {
 	//	self.ReturnError(403, apps.AccountError, "", nil)
 	//}
+	wxUser := user_model.GetWxUserById(wxUId, true)
+	if wxUser == nil {
+		self.ReturnError(403, apps.NoExist, "", nil)
+	}
 	orderType := order_model.ORDER_TYPE_NORMAL
 	//秒杀逻辑: 判断是否处于秒杀时间段内
 	if product.SeckilShowPrice > 0 {
@@ -89,7 +93,7 @@ func (self *OrderController) Create() {
 	}
 
 	order := new(order_model.Order).CreateNew(wxUId, uId,
-		totalPrice, freight, orderType, order_model.SOURCE_XCX)
+		totalPrice, freight, orderType, wxUser.Depart, order_model.SOURCE_XCX)
 	if order == nil {
 		self.ReturnError(403, apps.CreateOrderFail, "", nil)
 	}
@@ -138,10 +142,14 @@ func (self *OrderController) MultipleCreate() {
 	if len(nums) <= 0 || len(ids) <= 0 {
 		self.ReturnError(403, apps.NoCart, "", nil)
 	}
+	wxUser := user_model.GetWxUserById(wxUId, true)
+	if wxUser == nil {
+		self.ReturnError(403, apps.NoExist, "", nil)
+	}
 	totalPrice := int64(0)
 	//创建订单
 	order := new(order_model.Order).CreateNew(wxUId, uId,
-		totalPrice, int64(0), order_model.ORDER_TYPE_NORMAL, order_model.SOURCE_XCX)
+		totalPrice, int64(0), order_model.ORDER_TYPE_NORMAL, wxUser.Depart, order_model.SOURCE_XCX)
 	if order == nil {
 		self.ReturnError(403, apps.CreateOrderFail, "", nil)
 	}
@@ -203,7 +211,7 @@ func (self *OrderController) MultShopCreate() {
 	totalPrice := int64(0)
 	//创建订单
 	order := new(order_model.Order).CreateNew(wxUId, uId,
-		totalPrice, int64(0), order_model.ORDER_TYPE_SHOP, order_model.SOURCE_XCX)
+		totalPrice, int64(0), order_model.ORDER_TYPE_SHOP, wxUser.Depart, order_model.SOURCE_XCX)
 	if order == nil {
 		self.ReturnError(403, apps.CreateOrderFail, "", nil)
 	}
@@ -261,7 +269,7 @@ func (self *OrderController) MultCentCreate() {
 	totalPrice := int64(0)
 	//创建订单
 	order := new(order_model.Order).CreateNew(wxUId, uId,
-		totalPrice, int64(0), order_model.ORDER_TYPE_CENT, order_model.SOURCE_XCX)
+		totalPrice, int64(0), order_model.ORDER_TYPE_CENT, wxUser.Depart, order_model.SOURCE_XCX)
 	if order == nil {
 		self.ReturnError(403, apps.CreateOrderFail, "", nil)
 	}

+ 1 - 1
go/gopath/src/fohow.com/apps/controllers/pay_controller/recharge_controller.go

@@ -43,7 +43,7 @@ func (self *PayController) CreateBalanceOrder() {
 		tp = count
 	}
 	//初始化充值订单信息
-	balanceOrder := new(balance_model.BalanceOrder).Create(wxUser.Id, user.Id, tp, count, balance_model.PAY_WAY_TYPE_SERVICE_WXPAY)
+	balanceOrder := new(balance_model.BalanceOrder).Create(wxUser.Id, user.Id, tp, count, wxUser.Depart, balance_model.PAY_WAY_TYPE_SERVICE_WXPAY)
 
 	self.Data["json"] = balanceOrder
 	self.ServeJSON()

+ 4 - 1
go/gopath/src/fohow.com/apps/controllers/permit_controller/permit_controller.go

@@ -125,6 +125,7 @@ func (self *PermitController) XcxAuthorize() {
 		//首次授权
 		first = true
 		introUserId := int64(1)
+		depart := int64(0)
 		if inviteId == int64(0) {
 			inviteId = int64(1)
 		}
@@ -133,11 +134,13 @@ func (self *PermitController) XcxAuthorize() {
 		if inviter != nil {
 			if inviter.ShowInviteMode == 1 && inviteId != int64(1) {
 				introUserId = inviter.Id
+
 			} else {
 				introUserId = inviter.IntroUserId
 			}
+			depart = inviter.Depart
 		}
-		wxUser = new(user_model.WxUser).QuickCreate(encryptedData.OpenId, encryptedData.UnionId, ip, channel, time.Now().Unix(), user.Id, inviteId, introUserId)
+		wxUser = new(user_model.WxUser).QuickCreate(encryptedData.OpenId, encryptedData.UnionId, ip, channel, time.Now().Unix(), user.Id, inviteId, introUserId, depart)
 	}
 	user.Nickname = wxUser.Nickname
 	user.Country = wxUser.Country

+ 1 - 1
go/gopath/src/fohow.com/apps/controllers/user_controller/user_controller.go

@@ -430,7 +430,7 @@ func (self *UserController) ShopApplication() {
 	if record != nil {
 		self.ReturnError(403, apps.ShopNoRepit, "", nil)
 	}
-	record = new(user_model.ShopApplication).Create(user.Id, wxUser.Id, total, mobile, name, wxUser.Nickname, addr, remark)
+	record = new(user_model.ShopApplication).Create(user.Id, wxUser.Id, total, wxUser.Depart, mobile, name, wxUser.Nickname, addr, remark)
 	if record == nil {
 		self.ReturnError(403, apps.CreateOrderFail, "", nil)
 	}

+ 2 - 1
go/gopath/src/fohow.com/apps/models/balance_model/balance.go

@@ -323,7 +323,7 @@ func createOrderId(prefix string) string {
 	return oId
 }
 
-func (self *BalanceOrder) Create(wxUId, uId, tp, paidPrice int64, payway string) (item *BalanceOrder) {
+func (self *BalanceOrder) Create(wxUId, uId, tp, paidPrice, depart int64, payway string) (item *BalanceOrder) {
 	oId := createOrderId(ORDER_ID_PREFIX_CZ)
 	item = &BalanceOrder{
 		OrderId:    oId,
@@ -332,6 +332,7 @@ func (self *BalanceOrder) Create(wxUId, uId, tp, paidPrice int64, payway string)
 		PayWay:     payway,
 		TotalPrice: tp,
 		PaiedPrice: paidPrice,
+		Depart:     depart,
 		Remark:     "充值",
 	}
 	id, err := orm.NewOrm().Insert(item)

+ 2 - 1
go/gopath/src/fohow.com/apps/models/order_model/order.go

@@ -142,7 +142,7 @@ func (self *Order) Create(wxUserId, uId, count, totalPrice, buyPrice int64, sour
 }
 
 //新创建订单
-func (self *Order) CreateNew(wxUserId, uId, totalPrice, freight, orderType int64, source string) *Order {
+func (self *Order) CreateNew(wxUserId, uId, totalPrice, freight, orderType, depart int64, source string) *Order {
 	var oId string
 	oId = createOrderId(ORDER_ID_PREFIX_EX)
 	order := &Order{
@@ -154,6 +154,7 @@ func (self *Order) CreateNew(wxUserId, uId, totalPrice, freight, orderType int64
 		Status:     STATUS_UNPAY,
 		Source:     source,
 		OrderType:  orderType,
+		Depart:     depart,
 	}
 	id, err := orm.NewOrm().Insert(order)
 	if err != nil {

+ 2 - 1
go/gopath/src/fohow.com/apps/models/user_model/shop_application.go

@@ -37,7 +37,7 @@ func (self *ShopApplication) TableName() string {
 	return shop_applications_tablename
 }
 
-func (self *ShopApplication) Create(uId, wxUId, total int64, mobile, name, nickname, address, remark string) *ShopApplication {
+func (self *ShopApplication) Create(uId, wxUId, total, depart int64, mobile, name, nickname, address, remark string) *ShopApplication {
 	item := &ShopApplication{
 		UserId:   uId,
 		WxUId:    wxUId,
@@ -46,6 +46,7 @@ func (self *ShopApplication) Create(uId, wxUId, total int64, mobile, name, nickn
 		Mobile:   mobile,
 		Total:    total,
 		Address:  address,
+		Depart:   depart,
 		Remark:   remark,
 		Status:   false,
 	}

+ 2 - 1
go/gopath/src/fohow.com/apps/models/user_model/wx_user.go

@@ -73,7 +73,7 @@ func (self *WxUser) TableName() string {
 	return wx_users_tablename
 }
 
-func (self *WxUser) QuickCreate(openid, unionid, ip string, channel, lastConversationAt, userId, inviteId, introUserId int64) *WxUser {
+func (self *WxUser) QuickCreate(openid, unionid, ip string, channel, lastConversationAt, userId, inviteId, introUserId, depart int64) *WxUser {
 	item := &WxUser{
 		UserId:             userId,
 		Openid:             openid,
@@ -82,6 +82,7 @@ func (self *WxUser) QuickCreate(openid, unionid, ip string, channel, lastConvers
 		ChannelQrcodeId:    channel,
 		IntroUserId:        introUserId,
 		InviteId:           inviteId,
+		Depart:             depart,
 		LastConversationAt: lastConversationAt}
 	id, err := orm.NewOrm().Insert(item)
 	if err != nil {