UsersGoods.php 608 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2021/10/28 0028
  6. * Time: 22:39
  7. */
  8. namespace datamodel;
  9. use logicmodel\ChainLogic;
  10. use think\Log;
  11. class UsersGoods extends BaseDataModel
  12. {
  13. public function addHash($goodsHash){
  14. if(!$goodsHash){
  15. //throw new \Exception('未找到hash');
  16. Log::error("用户商品未找到hash,{$this['id']}");
  17. }else {
  18. $this['goods_hash'] = $goodsHash['hash'];
  19. }
  20. $this['user_hash']=ChainLogic::instance()->getGoodsHash(Goods::get($this['goods_id']));
  21. return $this->save();
  22. }
  23. }