Esempio n. 1
0
// 保存线上商店
func (this *shopService) SaveOnlineShop(s *shop.Shop, v *shop.OnlineShop) error {
	mch, err := this._mchRep.GetMerchant(s.MerchantId)
	if err == nil {
		mgr := mch.ShopManager()
		var sp shop.IShop
		if s.Id > 0 { // 保存商店
			sp = mgr.GetShop(s.Id)
			err = sp.SetValue(s)
			if err != nil {
				return err
			}
		} else {
			//检测店名是否重复
			if err = this.checkShopName(mgr, s.Id, s.Name); err != nil {
				return err
			}
			// 创建商店
			sp = mgr.CreateShop(s)
		}

		ofs := sp.(shop.IOnlineShop)
		err = ofs.SetShopValue(v)
		if err == nil {
			_, err = sp.Save()
		}
	}
	return err
}
Esempio n. 2
0
func (this *orderManagerImpl) SmartConfirmOrder(o order.IOrder) error {

	return nil

	//todo:  自动确认订单
	var err error
	v := o.GetValue()
	log.Printf("[ AUTO][OrderSetup]:%s - Confirm \n", v.OrderNo)
	var sp shop.IShop
	if biShops == nil {
		// /pay/return_alipay?out_trade_no=ZY1607375766&request_token=requestToken&result=success&trade_no
		// =2016070221001004880246862127&sign=75a18ca0d75750ac22fedbbe6468c187&sign_type=MD5
		//todo:  拆分订单
		biShops = this._merchant.ShopManager().GetBusinessInShops()
	}
	if len(biShops) == 1 {
		sp = biShops[0]
	} else {
		sp, err = this.SmartChoiceShop(v.ShippingAddress)
		if err != nil {
			//todo:
			panic("not impl")
			//order.Suspend("智能分配门店失败!原因:" + err.Error())
			return err
		}
	}

	if sp != nil && sp.Type() == shop.TypeOfflineShop {
		sv := sp.GetValue()
		//todo: set shop
		panic("not impl")
		//order.SetShop(sp.GetDomainId())
		err = o.Confirm()
		//err = order.Process()
		ofs := sp.(shop.IOfflineShop).GetShopValue()
		o.AppendLog(&order.OrderLog{
			Type:     int(order.LogSetup),
			IsSystem: 1,
			Message:  fmt.Sprintf("自动分配门店:%s,电话:%s", sv.Name, ofs.Tel),
		})
	}
	return err
}
Esempio n. 3
0
func (this *shopService) SaveShop(mchId int, v *shop.Shop) (int, error) {
	mch, err := this._mchRep.GetMerchant(mchId)
	if err != nil {

		log.Println("[ Merchant][ Service]-", err.Error())
		return 0, err
	}
	var shop shop.IShop
	if v.Id > 0 {
		shop = mch.ShopManager().GetShop(v.Id)
		if shop == nil {
			return 0, errors.New("门店不存在")
		}
	} else {
		shop = mch.ShopManager().CreateShop(v)
	}
	err = shop.SetValue(v)
	if err != nil {
		return v.Id, err
	}
	return shop.Save()
}
Esempio n. 4
0
func (this *shopManagerImpl) deleteOfflineShop(mchId int, s shop.IShop) error {
	shopId := s.GetDomainId()
	err := this._rep.DeleteOfflineShop(mchId, shopId)
	return err
}